Weitere ähnliche Inhalte Ähnlich wie Git tutorial II (20) Kürzlich hochgeladen (20) Git tutorial II2. Outline
• Review
• Collaboration
• Merge
• Rebase
• Simple GUI Demo
• Working on GitHub
4. Commands (I)
• git clone <repository>
• git status
• git log
• git diff
5. Commands (II)
• git add <files>
• git commit
• git branch <branch>
• git checkout <branch>
• git pull <remote> <branch>
• git push <remote> <branch>
6. Commit Cycle
• Update file
(Open the file and update its content manually)
• git add
• git commit
9. Merge
• A common option
• A complicated branch (tree)
10. Fetch & Pull
• git fetch - Update remote branches
• git pull - Update remote branches and current branch
12. Merge Cycle
• Checkout master
• Pull
• Merge
• Push
Initial
Your branch
13. Merge Cycle
• Checkout master
• Pull
• Merge
• Push
After Pull Your branch
Initial
14. Merge Cycle
• Checkout master
• Pull
• Merge
• Push
After Pull Your branch
Initial
Merge
15. Merge Cycle
• Checkout master
• Pull
• Merge
• Push
After Pull Your branch
Initial
Merge
Remote
Push
16. Merge Cycle
After Pull Your branch
Initial
Merge
Remote
Push
• git checkout master
• git pull
• git merge <your branch>
• git push origin master
18. Fix conflict
• Find the conflict part and fix them:
<<<<<<< HEAD
Original contents
=======
New contents
>>>>>>> test_merge
• Add updated files
• Commit
21. Exercise 5
• Add your introduction at the bottom of introduction.txt
• Checkout master
• Pull
• git merge <your branch>
• Fix conflict
• Push
22. Exercise 5
• Add your introduction at the bottom of introduction.txt
• git checkout master
• git pull
• git merge <your branch>
• Fix conflict
• git push origin master
23. Git Stash
• Stock your local difference (A queue)
• Prevent conflict on git pull
• Make branch be clean
24. Git Stash
• git stash
• git stash list
• git stash pop
• git stash drop
25. Rebase
• Trees are clean
• Work on single branch
• Each commit will be recreated.
That is, the commit number and timestamp will change.
27. Rebase Flow
• git commit
• git pull --rebase
• Fix conflict
• git add <fixed filename>
• git rebase --continue
• git push
28. Exercise 6
• Checkout master branch
• Add your student id into ids file
• Commit
• Pull by rebase and fix conflict if necessary
(git pull --rebase)
• Push
29. Merge / Rebase
• Choose the one you preferred.
• Merge is the default option.
• Rebase is more clean.
32. Fork / Pull Request
Fork
Someone’s Repo A cloned Repo
Update / Commit / Push
New commit in
Merge
Pull request your Repo
Pull request
33. Exercise 7
• Fork git-exercise-2
• Create files for comments to this session
• Commit / Push
• Pull request