Git
-
Upload
omar-al-sabek -
Category
Education
-
view
139 -
download
1
Transcript of Git
![Page 1: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/1.jpg)
![Page 2: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/2.jpg)
![Page 3: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/3.jpg)
![Page 4: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/4.jpg)
![Page 5: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/5.jpg)
![Page 6: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/6.jpg)
![Page 7: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/7.jpg)
![Page 8: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/8.jpg)
![Page 9: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/9.jpg)
![Page 10: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/10.jpg)
without git
feature 1 feature 2 feature 3 feature 4 feature 5
final
![Page 11: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/11.jpg)
project-v1
project
without git
project-v2 project-v3 project-final
![Page 12: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/12.jpg)
without git
?
![Page 13: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/13.jpg)
![Page 14: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/14.jpg)
![Page 15: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/15.jpg)
setting up git
![Page 16: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/16.jpg)
the basics
![Page 17: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/17.jpg)
Typical workflow
Person A
• Setup project
• push code onto github
• edit/commit
• edit/commit
• pull/push
Person B
• clone code from github
• edit/commit/push
• edit…
• edit… commit
• pull/push
![Page 18: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/18.jpg)
![Page 19: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/19.jpg)
parts of a git repository
working directory
staging area (index)
git directory(HEAD)
stage commit
checkout
![Page 20: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/20.jpg)
![Page 21: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/21.jpg)
![Page 22: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/22.jpg)
getting a git repository
git init
create one
git clone /path/to/repository
copy an existing repository
timeline
HEADmaster
timeline
HEADmaster
![Page 23: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/23.jpg)
checking project status
git status file status
untracked
unmodified
modified
staged
![Page 24: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/24.jpg)
tracking files / staging files
git add [filename]
git add [filename1] [filename2] [filename3]
git add . or git add *
untracked staged
modified staged
![Page 25: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/25.jpg)
committing changes
git commit
git commit –m “commit message”
staged unmodified
timeline
HEADmaster
![Page 26: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/26.jpg)
git work flow
create / delete / modify files
stage files
commit changes
[repeat]
git commit –am “commit message”
![Page 27: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/27.jpg)
removing files
git rm [filename]
git rm [filename1] [filename2] [filename3]
removes the file from the staging area and the working directory
![Page 28: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/28.jpg)
untracking files
git rm --cached [filename]
staged untracked
![Page 29: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/29.jpg)
undoing things
git checkout -- [filename]
discarding changes
modified unmodified
git reset HEAD [filename]
unstaging files
git reset HEAD
staged modified
![Page 30: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/30.jpg)
undoing things
git commit --amend
changing the last commit
git reset --soft HEAD
undoing the last commit
unmodified staged
git reset --hard HEAD discard all changes in last commit
![Page 31: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/31.jpg)
viewing changes
git diff
unstaged changes
git show [commit hash]
changes done in a commit
git diff --cached
staged changes
![Page 32: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/32.jpg)
viewing commit history
git log
git log --oneline
git log --graph
git log --since=“2013-12-01”
git log --author=“Lorem Ipsum”
git log --until=“2013-12-01”
![Page 33: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/33.jpg)
branching
![Page 34: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/34.jpg)
branching
timeline
HEAD
feature
master
git branch
list all branches
![Page 35: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/35.jpg)
creating a branch
git branch [branch name] git checkout [branch-name]
switch to the new branch
timeline
HEAD
[branch name]
master timeline
HEAD
[branch name]
master
git checkout –b [branch name]
![Page 36: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/36.jpg)
committing to branches
timeline
master
HEAD
feature
git commit –m “commit message”
![Page 37: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/37.jpg)
merging branches
git checkout [branch to merge into]
switch to the branch you want to merge into
git merge [branch to merge from]
perform merge
![Page 38: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/38.jpg)
deleting a branch
git checkout [some other branch]
switch to a branch other than the one to be deleted
git branch –d [branch name]
delete branch
![Page 39: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/39.jpg)
collaboration
![Page 40: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/40.jpg)
setting up for Github
sign up for a Github account
generate SSH key (if your machine currently doesn’t have one)
add your SSH key to your Github account
![Page 41: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/41.jpg)
two repositories
local repository- working directory- staging area- git directory
remote repository
- git directory
![Page 42: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/42.jpg)
remotes
git remote
showing all remotes
git remote -v
include remote URL
![Page 43: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/43.jpg)
managing remotes
git remote add [remote name] [remote URL]
creating a new remote
git remote rm [remote name]
deleting a remote
![Page 44: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/44.jpg)
data transfer to/from a remote
git push [remote name] [remote branch name]
sending data to a remote
git pull [remote name] [remote branch name]
getting data from a remote
![Page 45: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/45.jpg)
collaboration
![Page 46: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/46.jpg)
![Page 47: Git](https://reader034.fdocuments.us/reader034/viewer/2022051706/58ef55801a28ab31678b4617/html5/thumbnails/47.jpg)
Thanks For Listening