L&L_git
-
Upload
francois-baldassari -
Category
Documents
-
view
11 -
download
5
description
Transcript of L&L_git
![Page 1: L&L_git](https://reader031.fdocuments.us/reader031/viewer/2022020208/563db795550346aa9a8c68d6/html5/thumbnails/1.jpg)
9/16 L&L, “git”by francois
![Page 2: L&L_git](https://reader031.fdocuments.us/reader031/viewer/2022020208/563db795550346aa9a8c68d6/html5/thumbnails/2.jpg)
A UNIX programmer was working in the cubicle farms. As she saw Master Git traveling down the path, she ran to meet him. - “It is an honor to meet you, Master Git!” she said. “I have been studying the UNIX way of designing programs that each do one thing well. Surely I can learn much from you.” - “Surely,” replied Master Git. - “How should I change to a different branch?” asked the programmer. - “Use git checkout.” - “And how should I create a branch?” - “Use git checkout.” - “And how should I update the contents of a single file in my working directory, without involving branches at all?” - “Use git checkout.”
After this third answer, the programmer was enlightened.
![Page 3: L&L_git](https://reader031.fdocuments.us/reader031/viewer/2022020208/563db795550346aa9a8c68d6/html5/thumbnails/3.jpg)
Anatomy of a git repo
Content Addressable Filesystem
1st level tree: snapshot file hierarchy
2nd level tree: snapshots ordered by time
References (pointers)
![Page 4: L&L_git](https://reader031.fdocuments.us/reader031/viewer/2022020208/563db795550346aa9a8c68d6/html5/thumbnails/4.jpg)
Content Addressable FS
Source
FilenameSHA1
ZIP(1) Contents
objects dir
(1) Some files are saved as a pointer to a base file, and a file delta to save space
![Page 5: L&L_git](https://reader031.fdocuments.us/reader031/viewer/2022020208/563db795550346aa9a8c68d6/html5/thumbnails/5.jpg)
Snapshot File Hierarchy
Note: Trees are saved as files in the Content Addressable FS
![Page 6: L&L_git](https://reader031.fdocuments.us/reader031/viewer/2022020208/563db795550346aa9a8c68d6/html5/thumbnails/6.jpg)
Snapshots ordered by time
![Page 7: L&L_git](https://reader031.fdocuments.us/reader031/viewer/2022020208/563db795550346aa9a8c68d6/html5/thumbnails/7.jpg)
References
![Page 8: L&L_git](https://reader031.fdocuments.us/reader031/viewer/2022020208/563db795550346aa9a8c68d6/html5/thumbnails/8.jpg)
Why is this important?
Some things become easier once you understand them: • Branches & Tags are just pointers, moving them
doesn’t affect the commit tree • You cannot destroy a commit, only misplace it • All versions of the file are stored in the filesystem,
regardless of commits & branches
![Page 9: L&L_git](https://reader031.fdocuments.us/reader031/viewer/2022020208/563db795550346aa9a8c68d6/html5/thumbnails/9.jpg)
Stage & Working Dir
Think of the stage as a floating commitThe only thing you can lose is what is in your WD
![Page 10: L&L_git](https://reader031.fdocuments.us/reader031/viewer/2022020208/563db795550346aa9a8c68d6/html5/thumbnails/10.jpg)
What does commit do?
![Page 11: L&L_git](https://reader031.fdocuments.us/reader031/viewer/2022020208/563db795550346aa9a8c68d6/html5/thumbnails/11.jpg)
What does checkout do?
![Page 12: L&L_git](https://reader031.fdocuments.us/reader031/viewer/2022020208/563db795550346aa9a8c68d6/html5/thumbnails/12.jpg)
What does reset do?
![Page 13: L&L_git](https://reader031.fdocuments.us/reader031/viewer/2022020208/563db795550346aa9a8c68d6/html5/thumbnails/13.jpg)
Inspecting the commit tree
A: $ git log --graph --oneline --decorate
A: $ git log --no-merges --oneline
Q: What’s in my tree?
Q: What commits don’t come from merges?
Q: What commits are on the release branch but not master? A: $ git log master..release-3.5 —online
or $git log release-3.5 --not master --oneline
Q: How do master & branch differ?A: $ git log --left-right master...release-3.5 --oneline
![Page 14: L&L_git](https://reader031.fdocuments.us/reader031/viewer/2022020208/563db795550346aa9a8c68d6/html5/thumbnails/14.jpg)
Time Travel$ git checkout @{10 minutes ago}
$ git show master @{one.month.ago}
$ git diff @{yesterday}
$ git whatchanged --since="2 weeks ago"
![Page 15: L&L_git](https://reader031.fdocuments.us/reader031/viewer/2022020208/563db795550346aa9a8c68d6/html5/thumbnails/15.jpg)
The RefLog
![Page 16: L&L_git](https://reader031.fdocuments.us/reader031/viewer/2022020208/563db795550346aa9a8c68d6/html5/thumbnails/16.jpg)
Bisect
$ git bisect start
$ git checkout <known-bad-commit>
$ git bisect bad
$ git bisect good <known-good-commit>
… git selects the next commit to test …… test the commit …
$ git bisect <good or bad>
![Page 17: L&L_git](https://reader031.fdocuments.us/reader031/viewer/2022020208/563db795550346aa9a8c68d6/html5/thumbnails/17.jpg)
Share some tips & tricks https://pebbletechnology.atlassian.net/wiki/pages/
viewpage.action?pageId=44925274