Quick Introduction to git
-
Upload
joel-krebs -
Category
Entertainment & Humor
-
view
14.276 -
download
0
Transcript of Quick Introduction to git
![Page 1: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/1.jpg)
Joel Krebs
Slides by Oscar Nierstrasz
Distributed version control with git — a brief introduction
![Page 2: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/2.jpg)
Why git?
![Page 3: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/3.jpg)
Bob
![Page 4: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/4.jpg)
Bob Carol
![Page 5: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/5.jpg)
Bob Carol
Ted Alice
![Page 6: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/6.jpg)
Bob Carol
Ted Alice
A recipe for disaster!
![Page 7: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/7.jpg)
What is git?
![Page 8: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/8.jpg)
> Distributed revision control system
> Originally developed by Linus Torvalds for the development of the Linux Kernel in 2005
> Focus on speed and efficiency
> Quite a unique design and therefore sometimes a bit scary and difficult to understand
![Page 9: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/9.jpg)
The git object model
![Page 10: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/10.jpg)
blob
A “blob” is content under
version control (a file)
![Page 11: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/11.jpg)
You can have trees of blobs
(directories of files)
blob
blob
tree
tree
blob
![Page 12: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/12.jpg)
A “commit” is a tree of blobs
(a set of changes)
blob
commit
blob
tree
tree
blob
![Page 13: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/13.jpg)
Most commits modify
(or merge) earlier
commits
commit
blob
tree
blob
commit
blob
tree
tree
blob
![Page 14: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/14.jpg)
You can “tag” an
interesting commit
commit
blob
tree
tag
blob
commit
blob
tree
tree
blob
![Page 15: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/15.jpg)
A graph of commits
may belong to a branch
commit
blob
tree
tag
branch
blob
commit
blob
tree
tree
blob
![Page 16: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/16.jpg)
commit
blob
tree
tag
HEAD
branch
blob
commit
blob
tree
tree
blob
“HEAD “is the
current branch
![Page 17: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/17.jpg)
Let’s focus on commits
and branches
commit
HEAD
branch
commit
![Page 18: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/18.jpg)
Basic git
![Page 19: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/19.jpg)
Create a git repo
C0
HEAD
master
![Page 20: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/20.jpg)
Tell git to “stage”
changes
C0
HEAD
master
![Page 21: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/21.jpg)
C1
HEAD
master Commit your
changes
C0
![Page 22: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/22.jpg)
Collaborating
![Page 23: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/23.jpg)
Public repo Local repo
John Jane
Local repo
master
C1
C0
![Page 24: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/24.jpg)
Public repo Local repo
John Jane
Local repo
master master master
C1
C0
C1
C0
C1
C0
![Page 25: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/25.jpg)
Public repo Local repo
John Jane
Local repo
master master master
C0
C1
C0
C1
C1
C0
C2 C3
![Page 26: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/26.jpg)
Public repo Local repo
John Jane
Local repo
(nothing new to pull)
master master master
C0
C2 C3
C1
C0
C1
C1
C0
![Page 27: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/27.jpg)
Public repo Local repo
John Jane
Local repo
master master master
C0
C2
C1
C0
C3
C1
C0
C2
C1
![Page 28: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/28.jpg)
Public repo Local repo
John Jane
Local repo
master master master
C0
C2 C2
C1
C0
C3
C1
C0
C2
C1
![Page 29: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/29.jpg)
Public repo Local repo
John Jane
Local repo
NB: git pull = fetch + merge
C3
master
C1
C0
C2
master master
C0
C2 C2
C1
C0
C1
C4
![Page 30: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/30.jpg)
Public repo Local repo
John Jane
Local repo
C3
master
C1
C0
C2
master
C1
C0
C2
master
C0
C2
C3 C1
C4 C4
![Page 31: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/31.jpg)
Public repo Local repo
John Jane
Local repo
C3
master
C1
C0
C2 C3
master
C1
C0
C2 C3
master
C1
C0
C2
C4 C4 C4
![Page 32: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/32.jpg)
Branching
and merging
![Page 33: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/33.jpg)
“origin” refers to the
remote repo
C1
master
C0
origin/master
HEAD
![Page 34: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/34.jpg)
C1
master
C0
origin/master
HEAD
C2
![Page 35: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/35.jpg)
C1
master
C0
C2
tryout
origin/master
HEAD
![Page 36: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/36.jpg)
NB: git checkout –b … =
branch + checkout
C1
master
C0
C2
tryout
origin/master
HEAD
![Page 37: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/37.jpg)
C1
master
C0
C2
tryout
origin/master
HEAD
C3
![Page 38: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/38.jpg)
C1
master
C0
C2
tryout
C3
origin/idea
origin/master
HEAD
C4
C5
C6
![Page 39: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/39.jpg)
C1
master
C0
C2
tryout
C3
C4
C5
C6
origin/idea
origin/master
HEAD
C7
![Page 40: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/40.jpg)
C1
master
C0
C2
tryout HEAD
C3
C4
C5
C6
origin/idea
C7
origin/master
![Page 41: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/41.jpg)
C1
master
C0
C2
tryout
HEAD
C3
C4
C5
C6
origin/idea
C7
origin/master
C8
![Page 42: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/42.jpg)
C1
master
origin/master
C0
C2
tryout
HEAD
C3
C4
C5
C6
origin/idea
C8 C7
![Page 43: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/43.jpg)
Overview git workflow
Local repository
Working directory
Index (cache)
Remote repository
fetch
pull
push
commit
add
checkout
HEAD
![Page 44: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/44.jpg)
Getting started
![Page 45: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/45.jpg)
> Follow instructions on P2 Blog for installation
> Send your ssh public key to [email protected]
> Create meaningful commits with according messages
> Hints that make your life easier:
—Create a .gitignore file
—Always pull before you push
—Don’t panic when merge conflicts occur
First steps
![Page 46: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/46.jpg)
More to git
![Page 47: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/47.jpg)
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
> …
![Page 48: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/48.jpg)
Resources
http://book.git-scm.com/index.html http://git-scm.com/
https://github.com/
http://www.slideshare.net/chacon/getting-git http://oreilly.com/
http://gitready.com/
![Page 49: Quick Introduction to git](https://reader033.fdocuments.net/reader033/viewer/2022052915/58f9ae9c760da3da068ba46a/html5/thumbnails/49.jpg)
http://creativecommons.org/licenses/by-sa/3.0/