Git Introduction@d_danailov
Git IntroductionDimitar Danailov
Senior Developer at 158ltd.comdimityr.danailov[at]gmail.com
Slideshare.netGithub
YouTubeFounder at VarnaIT
Topics Today
● What is Git ?● Git Init● Git Branches● Git Merging● Git Conflicts
Git is an open source, distributed version control
system designed for speed and efficiency
Git is an open source, distributed version control
system designed for speed and efficiency
Git is an open source, distributed version control system designed for speed
and efficiency
Centralized source controlvs
distributed version control
Centralized source control
Computer A
Checkout
File
Central VSC Server
Version Database
Version 3
Version 2
Version 1
Computer A
Checkout
File
Central VSC Server
Version Database
Version 3
Version 2
Version 1
Computer B
Checkout
File
distributed version control
Computer BVersion Database
Computer AVersion Database
Version 3
Version 2
Version 1 Version 1
Version 2
Version 3
Server ComputerVersion Database
Version 3
Version 2
Version 1
Fully Distributed
(almost) everything is local
Git Configurations
git config --global user.name “My Name”
git config --global user.email “[email protected]”
git config --global color.ui true
Create an empty Git repository
touch hello_world.rbgit add hello_world.rb
git commit
git clonehttps://github.com/git/git
Edit files vim / emacs / etc
Stage the changes git add (file)
Review your changes git status / git diff
Commit the changes git commit
A Basic Workflow
Git Version Number
lightweight, movable pointers to a commit
Branch
C1
git checkout -b [branch_name]
git checkout [branch_name]
git merge [branch_name]
Master
Commit fb4d2f8
Master
Commitfb4d2f8
HeadHead is
pointer to current branch
Headgit branch i18n
Master
fb4d2f8
Headgit branch i18n
Master
i18n
fb4d2f8
Headgit branch i18n
Master
i18n
fb4d2f8
$ git branch* master* i18n
git branch i18n
fb4d2f8
Head
i18n
$ git branch* master* i18n
Master
git commit
fb4d2f8
Head
i18n
Master
e1c6bf1
git commit
fb4d2f8
Head
i18n
Master
e1c6bf1
git checkout -b iss53 master
fb4d2f8
Master
e1c6bf1
Head
i18n
32ac6d1
git checkout master;git checkout -b iss53
fb4d2f8
Master
e1c6bf1
i18n
32ac6d1
Head
iss53
fb4d2f8
Master
e1c6bf1
i18n
32ac6d1
k134ab1 a18cea1
iss53Head
git commit
fb4d2f8
Master
e1c6bf1
i18n
32ac6d1
k134ab1 a18cea1
iss53Head
git checkout master
fb4d2f8
Master
e1c6bf1
i18n
32ac6d1
k134ab1 a18cea1
iss53Head
git merge iss53
fb4d2f8
Master
e1c6bf1
i18n
32ac6d1
k134ab1 a18cea1
iss53Head
git checkout master
fast-forward merge
fb4d2f8
Master
e1c6bf1
i18n
32ac6d1
k134ab1 a18cea1
iss53Head
git merge iss53
fb4d2f8
Master
e1c6bf1
i18n
32ac6d1
k134ab1 a18cea1
iss53Head
git merge i18n
non fast-forward merge
fb4d2f8
Master
e1c6bf1
i18n
32ac6d1
k134ab1 a18cea1
iss53Head
git merge i18n
We need a new tree
fb4d2f8
Master
e1c6bf1
i18n
32ac6d1
k134ab1 a18cea1
iss53Head
git merge i18n
Lock History and find best merge base
fb4d2f8
Master
e1c6bf1
i18n
32ac6d1
k134ab1 a18cea1
iss53Head
git merge i18n
c3d Readme.txf13 Hello.c
c3d Readme.tx9ec Hello.c3ab i18n.c
c3d Readme.txf13 Hello.c5ff issue.c
fb4d2f8
Master
e1c6bf1
i18n
32ac6d1
k134ab1 a18cea1
iss53Head
git merge i18n
c3d Readme.txf13 Hello.c
c3d Readme.tx9ec Hello.c3ab i18n.c
c3d Readme.txf13 Hello.c5ff issue.c
Master
e1c6bf1
i18n
32ac6d1
k134ab1 a18cea1
iss53Head
git merge i18n
c3d Readme.tx9ec Hello.c3ab i18n.c
c3d Readme.txf13 Hello.c5ff issue.c
fb4d2f8c3d Readme.txf13 Hello.c
fb4d2f8c3d Readme.tx9ec Hello.c5ff issue.c3ab i18n.c
iss53
e1c6bf1
i18n
32ac6d1
k134ab1 a18cea1master
git merge i18n
c3d Readme.tx9ec Hello.c3ab i18n.c
c3d Readme.txf13 Hello.c5ff issue.c
fb4d2f8c3d Readme.txf13 Hello.c
fb4d2f8c3d Readme.tx9ec Hello.c5ff issue.c3ab i18n.c
Head
iss53
e1c6bf1
i18n
32ac6d1
k134ab1 a18cea1master
git merge i18n
fb4d2f8 954cba1
Head
● https://www.youtube.com/watch?v=ZDR433b0HJY&list=PLH2J_JZ4HZUtsholk1M9tQintjo-4rV8j● http://git-scm.com/● http://git-scm.com/book/en/v2/Git-Basics-Viewing-the-Commit-History
QuestionsDimitar Danailov
Senior Developer at 158ltd.comdimityr.danailov[at]gmail.com
Slideshare.netGithub
YouTubeFounder at VarnaIT