git : part 2 checkout, add, commit
DESCRIPTION
Git : Part 2 Checkout, Add, Commit. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Git : Part 2 Checkout, Add, Commit](https://reader035.vdocuments.us/reader035/viewer/2022062310/56815e6f550346895dccf0a3/html5/thumbnails/1.jpg)
Git : Part 2Checkout, Add, Commit
These slides were largely cut-and-pasted from http://excess.org/article/2008/07/ogre-git-tutorial/ ,
with some additions from other sources. I have deleted a lot from the cited tutorial, and recommend
that you listen to the entire tutorial on line, if you can.
![Page 2: Git : Part 2 Checkout, Add, Commit](https://reader035.vdocuments.us/reader035/viewer/2022062310/56815e6f550346895dccf0a3/html5/thumbnails/2.jpg)
Topics• Review• Creating an empty repository• Adding file changes to it• Committing the changes• Git naming conventions for commits• Git commands for getting information
about a repository
![Page 3: Git : Part 2 Checkout, Add, Commit](https://reader035.vdocuments.us/reader035/viewer/2022062310/56815e6f550346895dccf0a3/html5/thumbnails/3.jpg)
Review
Core git concepts
![Page 4: Git : Part 2 Checkout, Add, Commit](https://reader035.vdocuments.us/reader035/viewer/2022062310/56815e6f550346895dccf0a3/html5/thumbnails/4.jpg)
Git object model
http://utsl.gen.nz/talks/git-svn/git-model.png
![Page 5: Git : Part 2 Checkout, Add, Commit](https://reader035.vdocuments.us/reader035/viewer/2022062310/56815e6f550346895dccf0a3/html5/thumbnails/5.jpg)
Git componentsIndex– “staging area”– what is to be
committed
http://edgyu.excess.org/git-tutorial/2008-07-09/intro-to-git.pdf
![Page 6: Git : Part 2 Checkout, Add, Commit](https://reader035.vdocuments.us/reader035/viewer/2022062310/56815e6f550346895dccf0a3/html5/thumbnails/6.jpg)
Local Operations
add (stage) files
Working directory
Repository(.git directory)
Index (staging area)
checkout the project
commit
![Page 7: Git : Part 2 Checkout, Add, Commit](https://reader035.vdocuments.us/reader035/viewer/2022062310/56815e6f550346895dccf0a3/html5/thumbnails/7.jpg)
Git transport commands
http://osteele.com/images/2008/git-transport.png
![Page 8: Git : Part 2 Checkout, Add, Commit](https://reader035.vdocuments.us/reader035/viewer/2022062310/56815e6f550346895dccf0a3/html5/thumbnails/8.jpg)
Git init, add, commit
Using basic local operations to work on a single branch.
![Page 9: Git : Part 2 Checkout, Add, Commit](https://reader035.vdocuments.us/reader035/viewer/2022062310/56815e6f550346895dccf0a3/html5/thumbnails/9.jpg)
Bootstrapmkdir projectcd projectgit init
http://edgyu.excess.org/git-tutorial/2008-07-09/intro-to-git.pdf
![Page 10: Git : Part 2 Checkout, Add, Commit](https://reader035.vdocuments.us/reader035/viewer/2022062310/56815e6f550346895dccf0a3/html5/thumbnails/10.jpg)
Worktouch test
http://edgyu.excess.org/git-tutorial/2008-07-09/intro-to-git.pdf
![Page 11: Git : Part 2 Checkout, Add, Commit](https://reader035.vdocuments.us/reader035/viewer/2022062310/56815e6f550346895dccf0a3/html5/thumbnails/11.jpg)
Stagetouch testgit add test
http://edgyu.excess.org/git-tutorial/2008-07-09/intro-to-git.pdf
![Page 12: Git : Part 2 Checkout, Add, Commit](https://reader035.vdocuments.us/reader035/viewer/2022062310/56815e6f550346895dccf0a3/html5/thumbnails/12.jpg)
Committouch testgit add testgit commit –m”test”
http://edgyu.excess.org/git-tutorial/2008-07-09/intro-to-git.pdf
![Page 13: Git : Part 2 Checkout, Add, Commit](https://reader035.vdocuments.us/reader035/viewer/2022062310/56815e6f550346895dccf0a3/html5/thumbnails/13.jpg)
Work & Stagetouch testgit add testgit commit –m”test”mkdir direcho “foo” > dir/foogit add dir/foo
http://edgyu.excess.org/git-tutorial/2008-07-09/intro-to-git.pdf
![Page 14: Git : Part 2 Checkout, Add, Commit](https://reader035.vdocuments.us/reader035/viewer/2022062310/56815e6f550346895dccf0a3/html5/thumbnails/14.jpg)
Commit againtouch testgit add testgit commit –m”test”mkdir direcho “foo” > dir/foogit add dir/foogit commit –m”foo”
http://edgyu.excess.org/git-tutorial/2008-07-09/intro-to-git.pdf
![Page 15: Git : Part 2 Checkout, Add, Commit](https://reader035.vdocuments.us/reader035/viewer/2022062310/56815e6f550346895dccf0a3/html5/thumbnails/15.jpg)
Naming
How to refer to a commit
![Page 16: Git : Part 2 Checkout, Add, Commit](https://reader035.vdocuments.us/reader035/viewer/2022062310/56815e6f550346895dccf0a3/html5/thumbnails/16.jpg)
A commit can be identified by6bb1270ffb60cbfef87266d2d4b44abe4218d9c68
6bb127V1.5.6.1masterorigin/master“:/some text:HEADFETCH_HEADORIG_HEAD
full hashshort hashtaglocal branchremote branchmessagecheckoutlast fetchprevious head…
![Page 17: Git : Part 2 Checkout, Add, Commit](https://reader035.vdocuments.us/reader035/viewer/2022062310/56815e6f550346895dccf0a3/html5/thumbnails/17.jpg)
Other naming methodsHEAD^, HEAD^^, …MASTER^, MASTER^^, …HEAD~1, HEAD~2, …@{yesterday}, or HEAD@{yesterday}branchname@{June.1}master@{3}
HEAD
B
A HEAD^
![Page 18: Git : Part 2 Checkout, Add, Commit](https://reader035.vdocuments.us/reader035/viewer/2022062310/56815e6f550346895dccf0a3/html5/thumbnails/18.jpg)
Getting information
See the state of your repository, and review the
history.
![Page 19: Git : Part 2 Checkout, Add, Commit](https://reader035.vdocuments.us/reader035/viewer/2022062310/56815e6f550346895dccf0a3/html5/thumbnails/19.jpg)
git statusShows what is– Staged– Unstaged– Untracked
![Page 20: Git : Part 2 Checkout, Add, Commit](https://reader035.vdocuments.us/reader035/viewer/2022062310/56815e6f550346895dccf0a3/html5/thumbnails/20.jpg)
git diffgit diff– index vs. working files
git diff –staged– HEAD vs. index
git diff HEAD– HEAD vs. working files
git diff <commit1> <commit2>
![Page 21: Git : Part 2 Checkout, Add, Commit](https://reader035.vdocuments.us/reader035/viewer/2022062310/56815e6f550346895dccf0a3/html5/thumbnails/21.jpg)
git showgit show
– summarizes the last commitgit show –stat
– shows just the statisticsgit show –name-status
– shows status• Can apply to any commit
git show HEADgit show master^^…
• Or to a filegit show HEAD:file
![Page 22: Git : Part 2 Checkout, Add, Commit](https://reader035.vdocuments.us/reader035/viewer/2022062310/56815e6f550346895dccf0a3/html5/thumbnails/22.jpg)
git log• Shows history of changes• Can apply to any single commit or range
git loggit log tag..branchgit log HEAD~10..git log ~10
• Or attributes of commits, etc. etc.git log --since=“May 1” –until=“June 1”git log --author=fredgit log --grep-”commit.*message.*text”…
![Page 23: Git : Part 2 Checkout, Add, Commit](https://reader035.vdocuments.us/reader035/viewer/2022062310/56815e6f550346895dccf0a3/html5/thumbnails/23.jpg)
git grepgit grep –e “pattern” -- some/filegit grep –e “pattern” branch -- some/file
![Page 24: Git : Part 2 Checkout, Add, Commit](https://reader035.vdocuments.us/reader035/viewer/2022062310/56815e6f550346895dccf0a3/html5/thumbnails/24.jpg)
Viewing references• Named• Refer to commits• Can be moved• 3 basic types:–Tags–Local branches–Remote branches
![Page 25: Git : Part 2 Checkout, Add, Commit](https://reader035.vdocuments.us/reader035/viewer/2022062310/56815e6f550346895dccf0a3/html5/thumbnails/25.jpg)
TagsTo list tags: git tag –l
web2py1.74.11web2py1.74.9web2py1.75.2
Or look at the files in .git/refs/tags/
![Page 26: Git : Part 2 Checkout, Add, Commit](https://reader035.vdocuments.us/reader035/viewer/2022062310/56815e6f550346895dccf0a3/html5/thumbnails/26.jpg)
Local branchesTo list them: git branch –l
branch1 branch2* master
Or look at files in .git/refs/heads/
![Page 27: Git : Part 2 Checkout, Add, Commit](https://reader035.vdocuments.us/reader035/viewer/2022062310/56815e6f550346895dccf0a3/html5/thumbnails/27.jpg)
Remote branchesTo see them: git branch –r
origin/HEAD -> origin/master origin/master origin/update
Or look at files in .git/refs/remotes/