Git study notes

2,300 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,300
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
14
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Git study notes

  1. 1. Git Study Notes @angusli
  2. 2. 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
  3. 3. Who is using Git? • Git • Linux Kernel • Perl • Gnome • Qt • Ruby on Rails • Android • PostgreSQL • Wine • Fedora • Debian • X.org • …. and you?
  4. 4. 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
  5. 5. 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>
  6. 6. Step 1: Init project • git init • git add * • git commit -m "init comment“ • git clone /path/to/.git
  7. 7. Step 2: Change and modify file(1) from progit.org
  8. 8. Step 2: Change and modify file(2) from progit.org
  9. 9. 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
  10. 10. 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>
  11. 11. 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”
  12. 12. 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
  13. 13. 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
  14. 14. 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>
  15. 15. Step 8: Advanced Git • Submodules • Git servers • Hosted Git • Distributed Git • Git internals
  16. 16. 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
  17. 17. End

×