Git study notes
-
Upload
angus-li -
Category
Technology
-
view
1.944 -
download
1
Transcript of Git study notes
![Page 1: Git study notes](https://reader035.fdocuments.net/reader035/viewer/2022080213/55a65a2c1a28ab37798b458f/html5/thumbnails/1.jpg)
Git Study Notes
@angusli
![Page 2: Git study notes](https://reader035.fdocuments.net/reader035/viewer/2022080213/55a65a2c1a28ab37798b458f/html5/thumbnails/2.jpg)
What’s Git?
• Git is distributed version control system focused on speed, effectivity and real-world usability on large projects. Its highlights include:– Distributed development
– Strong support for non-linear development
– Efficient handling of large projects
– Cryptographic authentication of history
– Toolkit design
![Page 3: Git study notes](https://reader035.fdocuments.net/reader035/viewer/2022080213/55a65a2c1a28ab37798b458f/html5/thumbnails/3.jpg)
Who is using Git?
• Git• Linux Kernel• Perl• Gnome• Qt• Ruby on Rails• Android• PostgreSQL• Wine• Fedora• Debian• X.org• …. and you?
![Page 4: Git study notes](https://reader035.fdocuments.net/reader035/viewer/2022080213/55a65a2c1a28ab37798b458f/html5/thumbnails/4.jpg)
Study Notes
• Step 0: Environment setting and help
• Step 1: Init project
• Step 2: Change and modify file
• Step 3: Undo your stuff
• Step 4: View log
• Step 5: Tagging
• Step 6: Branching
• Step 7: Work with remotes
• Step 8: Advanced Git
![Page 5: Git study notes](https://reader035.fdocuments.net/reader035/viewer/2022080213/55a65a2c1a28ab37798b458f/html5/thumbnails/5.jpg)
Step 0: Env setting and help
• git config --list• git config --global user.name• git config --global user.email• <ready to go!>
• git help <verb>
![Page 6: Git study notes](https://reader035.fdocuments.net/reader035/viewer/2022080213/55a65a2c1a28ab37798b458f/html5/thumbnails/6.jpg)
Step 1: Init project
• git init• git add *• git commit -m "init comment“
• git clone /path/to/.git
![Page 7: Git study notes](https://reader035.fdocuments.net/reader035/viewer/2022080213/55a65a2c1a28ab37798b458f/html5/thumbnails/7.jpg)
Step 2: Change and modify file(1)
from progit.org
![Page 8: Git study notes](https://reader035.fdocuments.net/reader035/viewer/2022080213/55a65a2c1a28ab37798b458f/html5/thumbnails/8.jpg)
Step 2: Change and modify file(2)
from progit.org
![Page 9: Git study notes](https://reader035.fdocuments.net/reader035/viewer/2022080213/55a65a2c1a28ab37798b458f/html5/thumbnails/9.jpg)
Step 2: Change and modify file(3)
• git status• git add <file>
• git diff• git diff --cached
• git commit -m "edit commit“• git commit -a -m "auto commit“
• git mv
![Page 10: Git study notes](https://reader035.fdocuments.net/reader035/viewer/2022080213/55a65a2c1a28ab37798b458f/html5/thumbnails/10.jpg)
Step 3: Undo your stuff
• git revert <commit>• git commit -m "undo last commit and re-commit" –amend
• git rm <file>• git rm --cached <file>
• git reset <file>• git checkout <version> <file>
![Page 11: Git study notes](https://reader035.fdocuments.net/reader035/viewer/2022080213/55a65a2c1a28ab37798b458f/html5/thumbnails/11.jpg)
Step 4: View log
• git log -1• git log -p• git log -p -2
• git log --stat• git log --shortstat
• git log --pretty=oneline• git log --pretty="%h %cn: %s“• git log --pretty="%h %cn: %s" --graph
• git log --since/after/until/before=2.weeks/”2010-10-20”
![Page 12: Git study notes](https://reader035.fdocuments.net/reader035/viewer/2022080213/55a65a2c1a28ab37798b458f/html5/thumbnails/12.jpg)
Step 5: Tagging
• git tag• git tag -l "a*“
• git tag <tag-name>• git tag -a <tag-name> -m “comment”
• git show <tag-name>
• git tag <rev-hash>
• git push origin <tag-name>• git push --tags
![Page 13: Git study notes](https://reader035.fdocuments.net/reader035/viewer/2022080213/55a65a2c1a28ab37798b458f/html5/thumbnails/13.jpg)
Step 6: Branching
• git branch• git branch -v
• git branch <bname>• git checkout <bname>• git checkout -b <bname>
• git merge <bname>• git add <conflict-file>• git commit• git branch --merged/--no-merged
• git rebase• git rebase --continue/skip/abort
![Page 14: Git study notes](https://reader035.fdocuments.net/reader035/viewer/2022080213/55a65a2c1a28ab37798b458f/html5/thumbnails/14.jpg)
Step 7: Work with remotes
• git remote• git remote -v
• git remote add <origin-name> /path/to/.git• git remote show <origin-name>
• git pull• git fetch• git fetch <origin-name>• git merge <origin-name>/master
• git remote rename <origin-name> <name-name>• git remote rm <origin-name>
![Page 15: Git study notes](https://reader035.fdocuments.net/reader035/viewer/2022080213/55a65a2c1a28ab37798b458f/html5/thumbnails/15.jpg)
Step 8: Advanced Git
• Submodules• Git servers• Hosted Git• Distributed Git• Git internals
![Page 16: Git study notes](https://reader035.fdocuments.net/reader035/viewer/2022080213/55a65a2c1a28ab37798b458f/html5/thumbnails/16.jpg)
Git resources
• http://git-scm.com/• http://progit.org/• http://ktown.kde.org/~zrusin/git/git-cheat-sheet-large.png• http://www.kernel.org/pub/software/scm/git/docs/• http://www-cs-students.stanford.edu/~blynn/gitmagic/• http://stackoverflow.com/questions/315911/git-for-
beginners-the-definitive-practical-guide
![Page 17: Git study notes](https://reader035.fdocuments.net/reader035/viewer/2022080213/55a65a2c1a28ab37798b458f/html5/thumbnails/17.jpg)
End