Git study notes

17
Git Study Notes @angusli

Transcript of Git study notes

Page 1: Git study notes

Git Study Notes

@angusli

Page 2: Git study notes

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

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

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

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

Step 1: Init project

• git init• git add *• git commit -m "init comment“

• git clone /path/to/.git

Page 7: Git study notes

Step 2: Change and modify file(1)

from progit.org

Page 8: Git study notes

Step 2: Change and modify file(2)

from progit.org

Page 9: Git study notes

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

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

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

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

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

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

Step 8: Advanced Git

• Submodules• Git servers• Hosted Git• Distributed Git• Git internals

Page 16: Git study notes

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

End