28
REUTERS / Eric Gaillard Understanding GIT Tadeusz Balcer 12/5/2016

Understanding git

Embed Size (px)

Citation preview

Page 1: Understanding git

REUTERS / Eric Gaillard

Understanding GIT

Tadeusz Balcer12/5/2016

Page 2: Understanding git

Centralized Version Control System (CVCS) (SVN, Perforce)

Source: https://git-scm.com/book/en/v2/book/01-introduction/images/centralized.png

Page 3: Understanding git

Distributed Version Control System (DVCS) (GIT, Mercurial)

Source: https://git-scm.com/book/en/v2/book/01-introduction/images/distributed.png

Page 4: Understanding git

Typical CVCS - differences

Page 5: Understanding git

GIT – stream of snapshots.

Page 6: Understanding git

GIT features

• Snapshot, not differences• Nearly every operation is local (no need network connection to work)• GIT has integrity (SHA-1 checksums)• Generally only adds data (It is hard to get the system to do anything that is not undoable)• Three states of files (commited, modified, staged)

Page 7: Understanding git

The Three States

Source: https://git-scm.com/book/en/v2/book/01-introduction/images/areas.png

Page 8: Understanding git

REUTERS / Edgar Su

Creating commit is like saving your game before you battle the boss.

Page 9: Understanding git

Commit object

• pointer to the snapshot of content• author’s name and email• message• pointer to commit or commits that directly came before this commit (zero, one or many)

Page 10: Understanding git

Commit object

Source: https://git-scm.com/book/en/v2/book/03-git-branching/images/commit-and-tree.png

Page 11: Understanding git

Commit object

Source: https://git-scm.com/book/en/v2/book/03-git-branching/images/commits-and-parents.png

Page 12: Understanding git

REUTERS / Mario Anzuoni

Merge vs rebase

Page 13: Understanding git

Branch

Page 14: Understanding git

3-way merge algorithm

1. Find a suitable merge base B - a version of the file that is an ancestor of both of the new versions (X and Y), and usually the most recent such base (although there are cases where it will have to go back further, which is one of the features of gits default recursive merge)

2. Perform diffs of X with B and Y with B.3. Walk through the change blocks identified in the two diffs. If both

sides introduce the same change in the same spot, accept either one; if one introduces a change and the other leaves that region alone, introduce the change in the final; if both introduce changes in a spot, but they don't match, mark a conflict to be resolved manually.

Page 15: Understanding git

Merging

Page 16: Understanding git

Merging

Page 17: Understanding git

Merge conflicts

Page 18: Understanding git

Merge conflicts (merge.conflictstyle=diff3)

Page 19: Understanding git

Remote branches

Source: https://git-scm.com/book/en/v2/book/03-git-branching/images/remote-branches-2.png

Page 20: Understanding git

Remote branches

Source: https://git-scm.com/book/en/v2/book/03-git-branching/images/remote-branches-3.png

Page 21: Understanding git

Remote branches

Source: https://git-scm.com/book/en/v2/book/03-git-branching/images/remote-branches-5.png

Page 22: Understanding git

Distributed workflows

Source: https://git-scm.com/book/en/v2/book/05-distributed-git/images/integration-manager.png

Page 23: Understanding git

Rebase

Source: https://git-scm.com/book/en/v2/book/03-git-branching/images/basic-rebase-3.png

Page 24: Understanding git

Fast-Forward

Source: https://git-scm.com/book/en/v2/book/03-git-branching/images/basic-rebase-4.png

Page 25: Understanding git

Rebase

Source: https://git-scm.com/book/en/v2/book/03-git-branching/images/interesting-rebase-1.png

Page 26: Understanding git

Rebase

Source: https://git-scm.com/book/en/v2/book/03-git-branching/images/interesting-rebase-2.png

Page 27: Understanding git

Cherry-pick

Source: http://image.slidesharecdn.com/git-getreadytouseit-140228043813-phpapp02/95/git-get-ready-to-use-it-65-638.jpg?cb=1393562489

Page 28: Understanding git

Resources

https://sivapremv.wordpress.com/2015/01/21/git-version-control-an-interesting-infographic-view/http://code.snipcademy.com/tutorials/git/fundamentals/three-states-areashttps://git-scm.com/book/en/v2/Getting-Started-Git-Basicshttps://www.quora.com/How-does-Git-merge-work