l&l_git

17
9/16 L&L, “git” by francois

Upload: francois-baldassari

Post on 04-Jan-2016

11 views

Category:

Documents


5 download

DESCRIPTION

A lunch & learn presentation about git

TRANSCRIPT

Page 1: L&L_git

9/16 L&L, “git”by francois

Page 2: L&L_git

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

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

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

Snapshot File Hierarchy

Note: Trees are saved as files in the Content Addressable FS

Page 6: L&L_git

Snapshots ordered by time

Page 7: L&L_git

References

Page 8: L&L_git

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

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

What does commit do?

Page 11: L&L_git

What does checkout do?

Page 12: L&L_git

What does reset do?

Page 13: L&L_git

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

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

The RefLog

Page 16: L&L_git

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

Share some tips & tricks https://pebbletechnology.atlassian.net/wiki/pages/

viewpage.action?pageId=44925274