Top Banner
Andrei Chis Distributed version control with git — part 2 based on slides by Oscar Nierstrasz
32

Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based

Jul 11, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based

Andrei Chis

Distributed version control with git — part 2

based on slides by Oscar Nierstrasz

Page 2: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based

Branching and merging

Page 3: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based

Branching is like “Save as...” on an entire

directory

Page 4: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based

master

Page 5: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based

master

create branch

problemset1

Page 6: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based

master

when switching branches the entire content of the folder is replaced

problemset1

Page 7: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based

problemset1

Page 8: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based

edit filesin branch

master problemset1

Page 9: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based

master problemset1

switch to master branch

Page 10: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based

master

merge with problemset1 branch

problemset1

Page 11: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based

master

new version in master branch

problemset1

Page 12: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based

only one branch is active at a time

Page 13: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based

and now branching in git

Page 14: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based

“origin” refers to the remote repo

C1

master

C0

origin/master

HEAD

Page 15: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based

git add …git commit …

C1

master

C0

origin/master

HEAD

C2

Page 16: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based

git branch problemset1

C1

master

C0

C2

problemset1

origin/master

HEAD

Page 17: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based

git checkout problemset1

C1

master

C0

C2origin/master

HEAD

problemset1

Page 18: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based

git add …git commit …

C1

master

C0

C2origin/master

HEAD

C3

problemset1

Page 19: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based

git add …git commit …

C1

master

C0

C2origin/master

HEAD

C3

C4

problemset1

Page 20: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based

C1

master

C0

C4origin/master

HEAD

git checkout master

C2

C3

problemset1

Page 21: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based

C1

master

C0

C4origin/master

C3

HEAD

C5

C2git add …git commit …

problemset1

Page 22: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based

C1

master

C0

origin/master

HEAD

C5

C2 C4

problemset1

C3

Page 23: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based

C1

master

C0

C4origin/master

C3

HEAD

C6

C2

C5

git merge problemset1

problemset1

Page 24: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based

C1

master

C0

C4

C3

HEAD

C6

C2

C5

origin/mastergit push

problemset1

Page 25: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based

Commit messages matter!!!

Page 26: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based
Page 27: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based
Page 28: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based
Page 29: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based

More to git

Page 30: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based

More to git …

> Merging and mergetool> Squashing commits when merging> Resolving conflicts> User authentication with ssh> gitx and other graphical tools> git configure — remembering your name> git remote — multiple remote repos> github — an open source public repo> …

�30

Page 31: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based

Resources

http://book.git-scm.com/index.htmlhttp://git-scm.com/

https://github.com/

http://www.slideshare.net/chacon/getting-git http://oreilly.com/

Page 32: Distributed version control with git part 2 - SCG: SCGscg.unibe.ch/download/lectures/p2lab/20-02-28-week_02-Merging_In… · Distributed version control with git — part 2 based

http://creativecommons.org/licenses/by-sa/3.0/

Attribution-ShareAlike 3.0You are free:

▪ to copy, distribute, display, and perform the work▪ to make derivative works▪ to make commercial use of the work

Under the following conditions:

Attribution. You must attribute the work in the manner specified by the author or licensor.

Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one.

▪ For any reuse or distribution, you must make clear to others the license terms of this work.▪ Any of these conditions can be waived if you get permission from the copyright holder.

Your fair use and other rights are in no way affected by the above.