Your SlideShare is downloading. ×
Git in a Nutshell
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Git in a Nutshell

7,904
views

Published on

Reference: http://www.slideshare.net/chacon/getting-git

Reference: http://www.slideshare.net/chacon/getting-git

Published in: Technology

1 Comment
13 Likes
Statistics
Notes
No Downloads
Views
Total Views
7,904
On Slideshare
0
From Embeds
0
Number of Embeds
19
Actions
Shares
0
Downloads
135
Comments
1
Likes
13
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. •• /* */• –• – browser_ver6/ browser_ver5/
  • 2. ••
  • 3. ••
  • 4. •• 
  • 5. •• 
  • 6. •• 
  • 7. ••••
  • 8. • – • –• –
  • 9. • –
  • 10. git config --global user.name "Dan"git config --global user.email"Dan@example.org"
  • 11. •• – git init – git clone
  • 12. cd project/git init .git add .git commit –m "initial commit"
  • 13. [/tmp/foo] $ ls -lahtotal 12Kdrwxr-xr-x+ 1 Dan None 0 Feb 17 11:46 .drwxrwxrwt+ 1 Dan root 8.0K Feb 17 11:46 ..drwxr-xr-x+ 1 Dan None 4.0K Feb 17 11:19 .git-rw-r--r-- 1 Dan None 0 Feb 17 11:46 Hello.txt-rw-r--r-- 1 Dan None 0 Feb 17 11:46 README .git/
  • 14. [/tmp/foo] $ ls -lh .git-rw-r--r-- 1 Dan None 111 Feb 17 11:19 config-rw-r--r-- 1 Dan None 73 Feb 17 11:19 description-rw-r--r-- 1 Dan None 23 Feb 17 11:19 HEADdrwxr-xr-x+ 1 Dan None 4.0K Feb 17 11:19 hooksdrwxr-xr-x+ 1 Dan None 0 Feb 17 11:19 infodrwxr-xr-x+ 1 Dan None 0 Feb 17 11:19 objectsdrwxr-xr-x+ 1 Dan None 0 Feb 17 11:19 refs
  • 15. [/tmp/foo] $ git status# On branch master# Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)# modified: README## Untracked files:# (use "git add <file>..." to include in what will be committed)# Hellono changes added to commit (use "git add" and/or "git commit -a")
  • 16. [/tmp/foo] $ git status# On branch master# Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)# modified: README## Untracked files:# (use "git add <file>..." to include in what will be committed)# Hellono changes added to commit (use "git add" and/or "git commit -a")
  • 17. [/tmp/foo] $ git status# On branch master# Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)# modified: README## Untracked files:# (use "git add <file>..." to include in what will be committed)# Hellono changes added to commit (use "git add" and/or "git commit -a")
  • 18. [/tmp/foo] $ git status# On branch master# Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)# modified: README## Untracked files:# (use "git add <file>..." to include in what will be committed)# Hellono changes added to commit (use "git add" and/or "git commit -a")[/tmp/foo] $ git add .
  • 19. [/tmp/foo] $ git status# On branch master# Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)# modified: README## Untracked files:# (use "git add <file>..." to include in what will be committed)# Hellono changes added to commit (use "git add" and/or "git commit -a")[/tmp/foo] $ git add .[/tmp/foo] $ git status# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)# new file: Hello# modified: README
  • 20. [/tmp/foo] $ git status# On branch master# Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)# modified: README## Untracked files:# (use "git add <file>..." to include in what will be committed)# Hellono changes added to commit (use "git add" and/or "git commit -a")[/tmp/foo] $ git add . git commit[/tmp/foo] $ git status# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)# new file: Hello# modified: README
  • 21. git add
  • 22. git add
  • 23. git addgit commit
  • 24. • –• git commit -a• git mv git rm
  • 25. • –
  • 26. • – git add .• tmp/* log/* build/* .DS_Store Thumbs.db
  • 27. • – git add .• tmp/* log/* build/* .DS_Store Thumbs.db
  • 28. [/tmp/foo] $ git add .[/tmp/foo] $ git status# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)# new file: Hello# modified: README[/tmp/foo] $ git commit
  • 29. [/tmp/foo] $ git add .[/tmp/foo] $ git status# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)# new file: Hello# modified: README[/tmp/foo] $ git commit -m add hello, refactor README
  • 30. [/tmp/foo] $ git add .[/tmp/foo] $ git status# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)# new file: Hello# modified: README[/tmp/foo] $ git commit -m add hello, refactor README[master 356bbef] add hello, refactor README 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 Hello[/tmp/foo] $ git status# On branch masternothing to commit (working directory clean)
  • 31. [/tmp/git] $ git logcommit 5673d695fcce217b26d1a5956c1184ff62dc74f1Author: Junio C Hamano <gitster@pobox.com>Date: Wed Feb 16 14:33:22 2011 -0800 Merge branch maint * maint: parse_tag_buffer(): do not prefixcmp() out of rangecommit 759e84f07fd0fba2f3466b11b74146173d42cb6bAuthor: Junio C Hamano <gitster@pobox.com>Date: Wed Feb 16 14:33:11 2011 -0800 Merge branch maint-1.7.3 into maint * maint-1.7.3:
  • 32. [/tmp/git] $ git logcommit 5673d695fcce217b26d1a5956c1184ff62dc74f1Author: Junio C Hamano <gitster@pobox.com>Date: Wed Feb 16 14:33:22 2011 -0800 Merge branch maint * maint: parse_tag_buffer(): do not prefixcmp() out of rangecommit 759e84f07fd0fba2f3466b11b74146173d42cb6bAuthor: Junio C Hamano <gitster@pobox.com>Date: Wed Feb 16 14:33:11 2011 -0800 Merge branch maint-1.7.3 into maint * maint-1.7.3:
  • 33. [/tmp/git] $ git logcommit 5673d695fcce217b26d1a5956c1184ff62dc74f1Author: Junio C Hamano <gitster@pobox.com>Date: Wed Feb 16 14:33:22 2011 -0800 Merge branch maint * maint: parse_tag_buffer(): do not prefixcmp() out of rangecommit 759e84f07fd0fba2f3466b11b74146173d42cb6bAuthor: Junio C Hamano <gitster@pobox.com>Date: Wed Feb 16 14:33:11 2011 -0800 Merge branch maint-1.7.3 into maint * maint-1.7.3:
  • 34. [/tmp/git] $ git logcommit 5673d695fcce217b26d1a5956c1184ff62dc74f1Author: Junio C Hamano <gitster@pobox.com>Date: Wed Feb 16 14:33:22 2011 -0800 Merge branch maint * maint: parse_tag_buffer(): do not prefixcmp() out of rangecommit 759e84f07fd0fba2f3466b11b74146173d42cb6bAuthor: Junio C Hamano <gitster@pobox.com>Date: Wed Feb 16 14:33:11 2011 -0800 Merge branch maint-1.7.3 into maint * maint-1.7.3:
  • 35. [/tmp/git] $ git logcommit 5673d695fcce217b26d1a5956c1184ff62dc74f1Author: Junio C Hamano <gitster@pobox.com>Date: Wed Feb 16 14:33:22 2011 -0800 Merge branch maint * maint: parse_tag_buffer(): do not prefixcmp() out of rangecommit 759e84f07fd0fba2f3466b11b74146173d42cb6bAuthor: Junio C Hamano <gitster@pobox.com>Date: Wed Feb 16 14:33:11 2011 -0800 Merge branch maint-1.7.3 into maint * maint-1.7.3:
  • 36. [/tmp/git] $ git logcommit 5673d695fcce217b26d1a5956c1184ff62dc74f1Author: Junio C Hamano <gitster@pobox.com>Date: Wed Feb 16 14:33:22 2011 -0800 Merge branch maint * maint: parse_tag_buffer(): do not prefixcmp() out of rangecommit 759e84f07fd0fba2f3466b11b74146173d42cb6bAuthor: Junio C Hamano <gitster@pobox.com>Date: Wed Feb 16 14:33:11 2011 -0800 Merge branch maint-1.7.3 into maint * maint-1.7.3:
  • 37. [/tmp/git] $ git show HEADcommit ebbc1b128825df6f7500f5e34836390b24ca4966Author: Dannvix Chen <Dannvix@gmail.com>Date: Thu Feb 17 14:15:23 2011 +0800 improve README user experiencediff --git a/README b/READMEindex edb17cc..a40afab 100644--- a/README+++ b/README@@ -1 +1,2 @@ Git test+Balah balah
  • 38. [/tmp/git] $ $ git blame git.c85023577 (Junio C Hamano 2006-12-19 14:34:12 -0800 1) #include "builtin.h"2b11e317 (Johannes Schindel 2006-06-05 19:43:52 +0200 2) #include "cache.h"fd5c363d (Thiago Farina 2010-08-31 23:29:08 -0300 3) #include "exec_cmd.h"fd5c363d (Thiago Farina 2010-08-31 23:29:08 -0300 4) #include "help.h"575ba9d6 (Matthias Lederhof 2006-06-25 15:56:18 +0200 5) #include "quote.h"d8e96fd8 (Jeff King 2009-01-28 02:38:14 -0500 6) #include "run-command.h"8e49d503 (Andreas Ericsson 2005-11-16 00:31:25 +0100 7)4e10738a (Jeff King 2008-07-03 07:46:57 -0400 19) static int use_pager=-1;4e10738a (Jeff King 2008-07-03 07:46:57 -0400 20) struct pager_config {4e10738a (Jeff King 2008-07-03 07:46:57 -0400 21) const char *cmd;9bad7233 (Jeff King 2010-11-17 12:04:12 -0500 22) int want;9bad7233 (Jeff King 2010-11-17 12:04:12 -0500 23) char *value;4e10738a (Jeff King 2008-07-03 07:46:57 -0400 24) };4e10738a (Jeff King 2008-07-03 07:46:57 -0400 25)
  • 39. ••
  • 40. • –• – – –•
  • 41. [/tmp/foo] $ git branch* master
  • 42. [/tmp/foo] $ git branch* master
  • 43. [/tmp/foo] $ git branch* master[/tmp/foo] $ git checkout –b newideaSwitched to a new branch newidea[/tmp/foo] $ git branch master* newidea
  • 44. [/tmp/foo] $ git branch* master[/tmp/foo] $ git checkout –b newideaSwitched to a new branch newidea[/tmp/foo] $ git branch master* newidea git branch newidea git checkout newidea
  • 45. [/tmp/foo] $ git branch* master[/tmp/foo] $ git checkout –b newideaSwitched to a new branch newidea[/tmp/foo] $ git branch master* newidea[/tmp/foo] $ … vim newidea …[/tmp/foo] $ git commit –a –m improve README user experience
  • 46. [/tmp/foo] $ git branch* master[/tmp/foo] $ git checkout –b newideaSwitched to a new branch newidea[/tmp/foo] $ git branch master* newidea[/tmp/foo] $ … vim newidea …[/tmp/foo] $ git commit –a –m improve README user experience[/tmp/foo] $ git checkout master[/tmp/foo] $ git merge newideaUpdating 356bbef..ebbc1b1Fast-forward README | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
  • 47. [/tmp/foo] $ git branch* master[/tmp/foo] $ git checkout –b newideaSwitched to a new branch newidea[/tmp/foo] $ git branch master* newidea[/tmp/foo] $ … vim newidea …[/tmp/foo] $ git commit –a –m improve README user experience[/tmp/foo] $ git checkout master[/tmp/foo] $ git merge newideaUpdating 356bbef..ebbc1b1Fast-forward README | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
  • 48. [/tmp/foo] $ git branch* master[/tmp/foo] $ git checkout –b newideaSwitched to a new branch newidea[/tmp/foo] $ git branch master* newidea[/tmp/foo] $ … vim newidea …[/tmp/foo] $ git commit –a –m improve README user experience[/tmp/foo] $ git checkout master[/tmp/foo] $ git merge newideaUpdating 356bbef..ebbc1b1Fast-forward README | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
  • 49. [/tmp/foo] $ git branch* master[/tmp/foo] $ git checkout –b newideaSwitched to a new branch newidea[/tmp/foo] $ git branch master* newidea[/tmp/foo] $ … vim newidea …[/tmp/foo] $ git commit –a –m improve README user experience[/tmp/foo] $ git checkout master[/tmp/foo] $ git merge newideaUpdating 356bbef..ebbc1b1Fast-forward README | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
  • 50. [/tmp/foo] $ git branch* master[/tmp/foo] $ git checkout –b newideaSwitched to a new branch newidea[/tmp/foo] $ git branch master* newidea[/tmp/foo] $ … vim newidea …[/tmp/foo] $ git commit –a –m improve README user experience[/tmp/foo] $ git checkout master[/tmp/foo] $ git merge newideaUpdating 356bbef..ebbc1b1Fast-forward README | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
  • 51. [/tmp/foo] $ git branch* master[/tmp/foo] $ git checkout –b newideaSwitched to a new branch newidea[/tmp/foo] $ git branch master* newidea[/tmp/foo] $ … vim newidea …[/tmp/foo] $ git commit –a –m improve README user experience[/tmp/foo] $ git checkout master[/tmp/foo] $ git merge newideaUpdating 356bbef..ebbc1b1Fast-forward README | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
  • 52. [/tmp/foo] $ git branch* master[/tmp/foo] $ git checkout –b newideaSwitched to a new branch newidea[/tmp/foo] $ git branch master* newidea[/tmp/foo] $ … vim newidea …[/tmp/foo] $ git commit –a –m improve README user experience‘[/tmp/foo] $ git checkout master[/tmp/foo] $ git merge newideaUpdating 356bbef..ebbc1b1Fast-forward README | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)[/tmp/foo] $ git branch –d newidea
  • 53. [/tmp/foo] $ git clone git://git.kernel.org/pub/scm/git/git.gitInitialized empty Git repository in /tmp/git/.git/remote: Counting objects: 133887, done.remote: Compressing objects: 100% (32547/32547), done.remote: Total 133887 (delta 100281), reused 132921 (delta 99480)Receiving objects: 100% (133887/133887), 27.30 MiB | 76 KiB/s, done.Resolving deltas: 100% (100281/100281), done.[/tmp/foo] $ git push origin master
  • 54. [/tmp/foo] $ git clone git://git.kernel.org/pub/scm/git/git.gitInitialized empty Git repository in /tmp/git/.git/remote: Counting objects: 133887, done.remote: Compressing objects: 100% (32547/32547), done.remote: Total 133887 (delta 100281), reused 132921 (delta 99480)Receiving objects: 100% (133887/133887), 27.30 MiB | 76 KiB/s, done.Resolving deltas: 100% (100281/100281), done.[/tmp/foo] $ git push origin master
  • 55. • • – git config – git remove – git init – git fetch – git add – git pull – git commit – git clone – git status – git push – git log – git tag• • – git checkout – git diff – git branch – git apply – git merge – git format-patch – git rebase – git am
  • 56. • –• –• – –
  • 57. • – git instaweb --httpd=webrick – http://localhost:1234/
  • 58. •••••

×