Git introduction
-
Upload
kornel-lugosi -
Category
Technology
-
view
1.128 -
download
1
description
Transcript of Git introduction
![Page 1: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/1.jpg)
Git
Kornel Lugosi@Coornail
May 17, 2011
![Page 2: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/2.jpg)
Table of contentsVersion control
Distributed revision control
Repository
Adding, commiting
Tracking changes
Branches
Pushing, pulling
Submodules
Ranges and other identifications of hashes
Other fun stuff
Resources
![Page 3: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/3.jpg)
Version control
What?
![Page 4: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/4.jpg)
Version control
Why?
![Page 5: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/5.jpg)
Version control
Why?
◮ Backup
![Page 6: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/6.jpg)
Version control
Why?
◮ Backup
◮ Revision handling
![Page 7: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/7.jpg)
Version control
Why?
◮ Backup
◮ Revision handling
◮ Teamwork
![Page 8: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/8.jpg)
Version control
Why?
◮ Backup
◮ Revision handling
◮ Teamwork
◮ Organized code commit access and workflow
![Page 9: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/9.jpg)
Version control
Why?
◮ Backup
◮ Revision handling
◮ Teamwork
◮ Organized code commit access and workflow
◮ Deploying
![Page 10: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/10.jpg)
Version control
How?
![Page 11: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/11.jpg)
Version control
How?
◮ CVS
![Page 12: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/12.jpg)
Version control
How?
◮ CVS
◮ SVN
![Page 13: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/13.jpg)
Version control
How?
◮ CVS
◮ SVN
◮ Hg(Mercurial)
![Page 14: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/14.jpg)
Version control
How?
◮ CVS
◮ SVN
◮ Hg(Mercurial)
◮ bzr (Bazaar)
![Page 15: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/15.jpg)
Version control
How?
◮ CVS
◮ SVN
◮ Hg(Mercurial)
◮ bzr (Bazaar)
◮ ...
![Page 16: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/16.jpg)
Version control
How?
◮ CVS
◮ SVN
◮ Hg(Mercurial)
◮ bzr (Bazaar)
◮ ...
◮ Git
![Page 17: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/17.jpg)
Distributed revisioncontrol
![Page 18: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/18.jpg)
Repository
(Repo)
![Page 19: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/19.jpg)
Repository
$ git init
![Page 20: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/20.jpg)
Repository
$ git init
$ git init --bare
![Page 21: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/21.jpg)
Repository
$ git init
$ git init --bare
$ git init --bare --shared=group
![Page 22: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/22.jpg)
Let’s put some code in!
$ echo "some code" > index.php$ git add index.php
![Page 23: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/23.jpg)
Let’s put some code in!
$ echo "some code" > index.php$ git add index.php
Oh shit, it is only added to the “index“!
![Page 24: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/24.jpg)
Let’s put some code in!
$ echo "some code" > index.php$ git add index.php
Oh shit, it is only added to the “index“!Well, fuck that!
$ git commit -m "My first commit"
![Page 25: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/25.jpg)
Let’s put some code in!
$ echo "some code" > index.php$ git add index.php
Oh shit, it is only added to the “index“!Well, fuck that!
$ git commit -m "My first commit"
But it is not on the remote server yet!
$ git push ...
![Page 26: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/26.jpg)
Nobody is looking, let’s commiteverything!
$ cat > index.php<?php
Thousand lines of code...ˆD$ git commit -a
![Page 27: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/27.jpg)
What the hell did I do?
(in the working tree)$ git diff
![Page 28: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/28.jpg)
What the hell did I do a year ago?
$ git log
![Page 29: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/29.jpg)
I have no idea what I do
Let’s not show it toeveryone (yet)!
$ git branch experimental$ git checkout experimental
![Page 30: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/30.jpg)
What branch am I on?
$ git branch -a
![Page 31: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/31.jpg)
Turns out I am smart after all
$ git checkout master$ git merge experimental
![Page 32: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/32.jpg)
I was smart today
Let’s show it to everyone$ git push <repository> <refspec>
![Page 33: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/33.jpg)
I was smart today
Let’s show it to everyone$ git push <repository> <refspec>
Damn! Somebody was faster...Conflict =(
![Page 34: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/34.jpg)
My code, let me show it to you!
$ git clone <repository>
![Page 35: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/35.jpg)
My code, let me show it to you!
$ git clone <repository>
Okay, I already have you repo, I want to laugh atyour code!
boss$ git pull <repository>
![Page 36: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/36.jpg)
Tagging
$ git tag
![Page 37: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/37.jpg)
Submodules
![Page 38: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/38.jpg)
Submodules
$ git submodule add <repository><path>
![Page 39: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/39.jpg)
Submodules
$ git submodule add <repository><path>
From the root directory!
![Page 40: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/40.jpg)
Ranges
$ git log 0af56ffa..HEAD
![Page 41: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/41.jpg)
Ranges
$ git log 0af56ffa..HEAD
$ git diff v2.5..HEADˆ
![Page 42: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/42.jpg)
Ranges
$ git log 0af56ffa..HEAD
$ git diff v2.5..HEADˆ
$ git cherry-pick HEAD˜4..
![Page 43: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/43.jpg)
Other fun stuff
◮ $ git revert◮ $ git reset◮ $ git stash◮ $ git bisect◮ $ git rebase◮ $ git gc
![Page 44: Git introduction](https://reader034.fdocuments.us/reader034/viewer/2022042607/556a6a3ad8b42ab0468b4cda/html5/thumbnails/44.jpg)
Links
◮ Official git documentation
◮ github
◮ Git Cheat sheet