soonho kong - carnegie mellon school of computer …soonhok/talks/20140519_git.pdf · git ≃ dag...
TRANSCRIPT
![Page 1: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/1.jpg)
Soonho KongSoonho Kong
2014/05/19, CMU
http://www.cs.cmu.edu/~soonhok
![Page 2: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/2.jpg)
IntroductionIntroduction
![Page 3: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/3.jpg)
![Page 4: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/4.jpg)
Google Trend: git vs. svn
![Page 5: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/5.jpg)
Ohloh: Compare Repositories
![Page 6: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/6.jpg)
Git: "The stupid content tracker"
![Page 7: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/7.jpg)
"I did not really expect anyone to use itbecause it’s so hard to use…"
-"Linus Torvalds goes off on Linux and Git"(Fake Interview)
![Page 8: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/8.jpg)
ConceptsConcepts
![Page 9: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/9.jpg)
Git Git DAG DAG≃≃
"Once you realize that git is just a DAGwith commit objects as vertices,and pointers (refs) into that graph,
it becomes a lot simpler to understand"
![Page 10: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/10.jpg)
Git Git DAG DAG≃≃
Repository Graph≃Node (Commit) Files≃
Label (refs) Branch / Tag / etc≃
![Page 11: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/11.jpg)
Commit Three Stage ThinkingCommit Three Stage Thinking
working staging history
![Page 12: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/12.jpg)
Commit Three Stage ThinkingCommit Three Stage Thinking
working staging history
![Page 13: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/13.jpg)
Commit Three Stage ThinkingCommit Three Stage Thinking
working staging historyadd
![Page 14: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/14.jpg)
Commit Three Stage ThinkingCommit Three Stage Thinking
working staging historyadd commit
![Page 15: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/15.jpg)
WorkflowWorkflow
![Page 16: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/16.jpg)
Install and ConfigInstall and Config
![Page 17: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/17.jpg)
InstallInstallOSX
$ brew install git
Linux$ sudo apt-get install git
WindowsVisit http://git-scm.com/
![Page 18: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/18.jpg)
Config: Name & EmailConfig: Name & Email$ git config --global user.name "your-name"$ git config --global user.email "your-email-address"
![Page 19: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/19.jpg)
Config: Useful SettingsConfig: Useful Settings# Colorize console output$ git config --global color.ui auto
# Force files to be LF on Mac/Linux$ git config --global core.autocrlf input
# Force Windows to convert to CRLF# on checkout and to LF on `add`$ git config --global core.autocrlf true
![Page 20: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/20.jpg)
Config: Like a Boss!Config: Like a Boss!By default for "git log –all"
![Page 21: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/21.jpg)
Config: Like a Boss!Config: Like a Boss!Now, "git la"
http://www.jayway.com/2012/11/27/configure-git-like-a-boss/
![Page 22: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/22.jpg)
Basic(init/add/commit)Basic(init/add/commit)http://try.github.io
![Page 23: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/23.jpg)
InitInitFrom Scratch
# New project$ git init newproject$ cd newproject# ...start coding
![Page 24: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/24.jpg)
InitInitFrom Existing Dir
# Legacy project tree$ cd existingproject$ git init
# Add all the code$ git add .$ git commit -m "Initial import"
![Page 25: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/25.jpg)
Commit Your First CommitCommit Your First Commitgit add git statusgit commit -m "Helpful message"
![Page 26: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/26.jpg)
NetworkNetwork
![Page 27: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/27.jpg)
NetworkNetwork
local
![Page 28: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/28.jpg)
NetworkNetwork
local origin
![Page 29: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/29.jpg)
NetworkNetwork
![Page 30: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/30.jpg)
NetworkNetwork
local originclone
$ git clone [email protected]:soonhokong/drealCloning into 'dreal'...remote: Reusing existing pack: 79707, done.remote: Counting objects: 127, done.remote: Compressing objects: 100% (98/98), done.remote: Total 79834 (delta 37), reused 74 (delta 29)Receiving objects: 100% (79834/79834), 49.25 MiB | 2.34 MiB/s, done.Resolving deltas: 100% (39555/39555), done.Checking connectivity... done.
![Page 31: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/31.jpg)
NetworkNetwork
local originclone
$ git remote -vorigin [email protected]:soonhokong/dreal (fetch)origin [email protected]:soonhokong/dreal (push)
![Page 32: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/32.jpg)
NetworkNetwork
local originpush
$ git pushCounting objects: 9, done.Delta compression using up to 4 threads.Compressing objects: 100% (3/3), done.Writing objects: 100% (3/3), 286 bytes | 0 bytes/s, done.Total 3 (delta 2), reused 0 (delta 0)To [email protected]:soonhokong/dreal bee5818..40155b4 master -> master
![Page 33: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/33.jpg)
NetworkNetwork
local originpush
remotesfetch
$ git fetch originremote: Counting objects: 3, done.remote: Compressing objects: 100% (3/3), done.remote: Total 3 (delta 0), reused 0 (delta 0)Unpacking objects: 100% (3/3), done.From github.com:soonhokong/dreal bee5818..40155b4 master -> origin/master
![Page 34: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/34.jpg)
NetworkNetwork
local originpush
remotesfetch
merge
$ git merge origin/masterUpdating bee5818..40155b4Fast-forward README.md | 1 + 1 file changed, 1 insertion(+)
![Page 35: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/35.jpg)
NetworkNetwork
local originpush
remotespull
pull
$ git pull origin masterFrom github.com:soonhokong/dreal * branch master -> FETCH_HEADUpdating bee5818..40155b4Fast-forward README.md | 1 + 1 file changed, 1 insertion(+)
![Page 36: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/36.jpg)
NetworkNetwork
local originpush
remotespull
pull
Don't use git pull!Use git fetch and then git rebase (or git merge)
http://longair.net/blog/2009/04/16/git-fetch-and-merge
![Page 37: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/37.jpg)
Centralized WorkflowCentralized Workflow
![Page 38: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/38.jpg)
Centralized WorkflowCentralized Workflow
The way people are using SVN
![Page 39: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/39.jpg)
Centralized WorkflowCentralized Workflow
You can use git in this way, too
![Page 40: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/40.jpg)
Centralized WorkflowCentralized WorkflowWhat's a problem?
![Page 41: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/41.jpg)
Problem of Centralized WorkflowProblem of Centralized Workflow
I'm working at CMU…
![Page 42: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/42.jpg)
Problem of Centralized WorkflowProblem of Centralized Workflow
I want to go home and resume the work.
![Page 43: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/43.jpg)
Problem of Centralized WorkflowProblem of Centralized Workflow
So I push what I've done so far to the repo
![Page 44: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/44.jpg)
Problem of Centralized WorkflowProblem of Centralized Workflow
@Home, I pull what I pushed and resume the work.
![Page 45: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/45.jpg)
Problem of Centralized WorkflowProblem of Centralized Workflow
In the meantime, Leo pushed a commit to the repo.
![Page 46: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/46.jpg)
Problem of Centralized WorkflowProblem of Centralized Workflow
I finished my part at home, push to the repo.
![Page 47: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/47.jpg)
Problem of Centralized WorkflowProblem of Centralized Workflow
Problem: Repo will be filled with intermediate commits
![Page 48: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/48.jpg)
Problem of Centralized WorkflowProblem of Centralized Workflow
Problem: Single Sync Point = Merge Conflicts↑
![Page 49: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/49.jpg)
Problem of Centralized WorkflowProblem of Centralized Workflow
Not Scalable ( 5 members)≤
![Page 50: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/50.jpg)
Distributed workflowDistributed workflow
![Page 51: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/51.jpg)
Distributed workflowDistributed workflow
There is the Blessed repository.
![Page 52: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/52.jpg)
Distributed workflowDistributed workflow
![Page 53: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/53.jpg)
Distributed workflowDistributed workflow
![Page 54: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/54.jpg)
Distributed workflowDistributed workflow
![Page 55: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/55.jpg)
Distributed workflowDistributed workflow
Clone personal repo (origin):$ git clone [email protected]:soonhokong/dreal.git$ git remote -vorigin [email protected]:soonhokong/dreal.git (fetch)origin [email protected]:soonhokong/dreal.git (push)
Add blessed repo:$ git remote add blessed [email protected]:dreal/dreal$ git remote -vblessed [email protected]:dreal/dreal.git (fetch)blessed [email protected]:dreal/dreal.git (push)origin [email protected]:soonhokong/dreal.git (fetch)origin [email protected]:soonhokong/dreal.git (push)
![Page 56: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/56.jpg)
Distributed workflowDistributed workflow
Most of time, we push to personal repos.
![Page 57: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/57.jpg)
Distributed workflowDistributed workflow
You can do destructive update (forced push) on your repo.
![Page 58: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/58.jpg)
Distributed workflowDistributed workflow
When the work is solid, we push to the blessed.
![Page 59: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/59.jpg)
Distributed workflowDistributed workflow
or make a pull-request.https://help.github.com/articles/using-pull-requests
![Page 60: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/60.jpg)
RebaseRebaseMany meaningful git operations
can be expressedin terms of the rebase command.
![Page 61: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/61.jpg)
Merge vs. RebaseMerge vs. Rebase
![Page 62: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/62.jpg)
Merge vs. RebaseMerge vs. Rebase
![Page 63: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/63.jpg)
Merge vs. RebaseMerge vs. Rebase
![Page 64: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/64.jpg)
Merge vs. RebaseMerge vs. Rebase
![Page 65: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/65.jpg)
Merge vs. RebaseMerge vs. Rebase$ git push blessed masterCounting objects: 28, done.Delta compression using up to 4 threads.Compressing objects: 100% (9/9), done.Writing objects: 100% (9/9), 955 bytes | 0 bytes/s, done.Total 9 (delta 6), reused 0 (delta 0)To [email protected]:dreal/dreal.git ! [rejected] master -> master (non-fast-forward)error: failed to push some refs to '[email protected]:dreal/dreal.git'hint: Updates were rejected because a pushed branch tip is behind its remotehint: counterpart. Check out this branch and integrate the remote changeshint: (e.g. 'git pull ...') before pushing again.hint: See the 'Note about fast-forwards' in 'git push --help' for details.
non-fast-forward??
![Page 66: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/66.jpg)
Merge vs. RebaseMerge vs. Rebase
![Page 67: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/67.jpg)
Merge vs. RebaseMerge vs. Rebase
![Page 68: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/68.jpg)
MergeMerge vs. Rebase vs. Rebase
![Page 69: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/69.jpg)
MergeMerge vs. Rebase vs. Rebase
![Page 70: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/70.jpg)
MergeMerge vs. Rebase vs. Rebase
OK?
![Page 71: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/71.jpg)
MergeMerge vs. Rebase vs. Rebase
OK?
![Page 72: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/72.jpg)
MergeMerge vs. Rebase vs. Rebase
Merge Hell
![Page 73: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/73.jpg)
Version Controll PitfallsVersion Controll Pitfalls1. History should be written in chronological order.2. Commits are immutable and immovable objects.
git rebase will free you!!
![Page 74: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/74.jpg)
Merge vs. RebaseMerge vs. Rebase
![Page 75: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/75.jpg)
Merge vs. Merge vs. RebaseRebase
![Page 76: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/76.jpg)
Merge vs. Merge vs. RebaseRebase
![Page 77: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/77.jpg)
Merge vs. Merge vs. RebaseRebase
![Page 78: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/78.jpg)
Merge vs. Merge vs. RebaseRebase
![Page 79: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/79.jpg)
Interactive RebaseInteractive Rebase
![Page 80: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/80.jpg)
Interactive RebaseInteractive Rebase
![Page 81: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/81.jpg)
Interactive RebaseInteractive Rebase
![Page 82: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/82.jpg)
Interactive RebaseInteractive Rebase
![Page 83: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/83.jpg)
Interactive RebaseInteractive Rebase
I want to combine the three commits into one.
![Page 84: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/84.jpg)
Interactive RebaseInteractive Rebase
git rebase origin/master doesn't do anything.
![Page 85: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/85.jpg)
Interactive RebaseInteractive Rebase
Run git rebase -i origin/master
![Page 86: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/86.jpg)
Interactive RebaseInteractive RebaseRun git rebase -i origin/master
pick 40155b4 Fix an Issue #1pick 42e5db9 Minor Fix of Previous Fixpick a31c7cd Minor Minor Fix or Previous Fix
# Rebase ec2ae2b..cf0977c onto ec2ae2b## Commands:# p, pick = use commit# r, reword = use commit, but edit the commit message# e, edit = use commit, but stop for amending# s, squash = use commit, but meld into previous commit# f, fixup = like "squash", but discard this commit's log message# x, exec = run command (the rest of the line) using shell## These lines can be re-ordered; they are executed from top to bottom.## If you remove a line here THAT COMMIT WILL BE LOST.## However, if you remove everything, the rebase will be aborted.#
![Page 87: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/87.jpg)
Interactive RebaseInteractive RebaseRun git rebase -i origin/master
pick 40155b4 Fix an Issue #1f 42e5db9 Minor Fix of Previous Fixf a31c7cd Minor Minor Fix or Previous Fix
# Rebase ec2ae2b..cf0977c onto ec2ae2b## Commands:# p, pick = use commit# r, reword = use commit, but edit the commit message# e, edit = use commit, but stop for amending# s, squash = use commit, but meld into previous commit# f, fixup = like "squash", but discard this commit's log message# x, exec = run command (the rest of the line) using shell## These lines can be re-ordered; they are executed from top to bottom.## If you remove a line here THAT COMMIT WILL BE LOST.## However, if you remove everything, the rebase will be aborted.#
![Page 88: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/88.jpg)
Interactive RebaseInteractive Rebase
![Page 89: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/89.jpg)
WarningWarning on Rebase on Rebase
Rebase will create a new commit.
![Page 90: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/90.jpg)
WarningWarning on Rebase on Rebase
It's OK to rebase and destructively update personal repo.
![Page 91: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/91.jpg)
WarningWarning on Rebase on Rebase
It's OK to rebase and destructively update personal repo.
![Page 92: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/92.jpg)
WarningWarning on Rebase on Rebase
But you should not destructively update the blessed repo.
![Page 93: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/93.jpg)
WarningWarning on Rebase on Rebase
Because other users base on blessed/master.
![Page 94: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/94.jpg)
ResetReset"Git Reset Demystified"
http://git-scm.com/blog/2011/07/11/reset.html
![Page 95: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/95.jpg)
Magit (emacs's git-mode)Magit (emacs's git-mode)(Available from package-list)
https://github.com/mtdavidson/magit-cheatsheet/http://vickychijwani.github.io/2011/09/09/Magit-Part-I/http://vickychijwani.github.io/2011/11/26/An-Introduction-to-Magit-Part-II/
![Page 96: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/96.jpg)
Github tipsGithub tipshttps://github.com/tiimgreen/github-cheat-sheet
![Page 97: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/97.jpg)
Other Useful ResourcesOther Useful ResourcesQuick Guide : Complete Reference : Visual Git Reference :
Nice Interactive Tutorial on Git Branches:
http://rogerdudler.github.io/git-guide/http://git-scm.com/book
http://marklodato.github.io/visual-git-guide/index-en.html
http://pcottle.github.io/learnGitBranching/
![Page 98: Soonho Kong - Carnegie Mellon School of Computer …soonhok/talks/20140519_Git.pdf · Git ≃ DAG "Once you realize that git is just a DAG with commit objects as vertices, and pointers](https://reader030.vdocuments.us/reader030/viewer/2022020303/5b8a87bc7f8b9a287e8ecf40/html5/thumbnails/98.jpg)
Thank youThank you