Version Control With Git
Version Control With Git
2 SYNCHRONIZATION
3 UNDO
5 SANDBOXING
6 BRANCHING
5
Version control
types
Version Control with Git. DevTestOps training.
VCS types
7
Lock-modify-unlock strategy
Locked by Alice
song.txt
Sword and spear
Wall of shields
ALICE BOB
8
Lock-modify-unlock strategy
song.txt
Sword and spear Sword and spear
Wall of shields Wall of shields
ALICE BOB
9
Lock-modify-unlock strategy
song.txt
Sword and spear Sword and spear
Wall of shields Wall of shields
Standing strong
On this their chosen battle field
ALICE BOB
10
Lock-modify-unlock strategy
song.txt
Sword and spear Sword and spear
Wall of shields Wall of shields
Standing strong
On this their chosen battle field
ALICE BOB
11
Copy-modify-merge strategy
song.txt
Sword and spear Standing strong
Wall of shields On this their chosen battle field
ALICE BOB
12
Copy-modify-merge strategy
song.txt
Sword and spear Standing strong
Wall of shields On this their chosen battle field
ALICE BOB
13
Centralized vs Distributed
SERVER SERVER
COMPUTER 1 COMPUTER 2
14
Why Git
• Git is released under the GNU General Public License version 2.0,
which is an open source license. The Git project chose to use GPLv2
to guarantee your freedom to share and change free software - to
make sure the software is free for all its users.
16
Git benefits
17
Download,
install, configure
Version Control with Git. DevTestOps training.
Download, install, configure
D O W N L O A D & I N S TA L L CONFIGURE
19
Create a github
repo and clone it
Version Control with Git. DevTestOps training.
Create github repository and clone it
• Simple as it can be
• Don’t forget to select “Initialize this repository with a README”
21
Create github repository
22
Cloning the repository
Select folder
Check content
Clone repo
Go to target dir
See content
23
Commit and push
25
Push in to github
26
Pull from remote
Commit changes
28
Create commit in github and pull it
29
Git GUI & gitk
Local branch
git reset HEAD^^ (HEAD~2)
git commit --amend -m “commit message” COMMIT
Remote repository
git revert <sha1> REMOTE REPOSITORY
32
Git revert
Local branch
git reset HEAD^^ (HEAD~2)
git commit --amend -m “commit message” COMMIT
Remote repository
git revert <sha1> REMOTE REPOSITORY
34
Git reset
FILE SYSTEM
git add
COMMIT
36
.gitignore
# no .log files
*.log
38
Branching and
merge
Version Control with Git. DevTestOps training.
Branch concept
Small feature
master
A B C D
Large feature
40
Fast-forward merge
HEAD
master
in feature
A B C
D E F
HEAD feature
in master
41
Fast-forward merge
HEAD
in feature
A B C
master
D E F
feature
HEAD
in master
42
Non fast-forward merge
HEAD
in master
master
A B C D
F G H
feature
HEAD
in feature
43
Non fast-forward merge
HEAD
in master
master
A B C D X
feature
F G H
HEAD
in feature
44
Conflict solving
S O LV E C O N F L I C T AVO I D C O N F L I C T
Resolve manually
git diff
Undo merge
git revert 09fe472
46
Rebase
master
A B C
1 2
HEAD feature
in master
HEAD
in feature
48
Rebase
master
A B C D E
1 2
HEAD feature
in master
HEAD
in feature
49
Rebase
master
A B C D E
1 2
HEAD feature
in master
HEAD
in feature
50
Golden rule of Rebase
master
A B C 1 2 D E
HEAD
in master
JUST DON’T DO IT
51
Cherry-pick
master
A B C D E
1 2
HEAD feature
in master
HEAD
in feature
53
Cherry-pick
master
A B C D E
1 2 D
HEAD
in master feature
HEAD
in feature
54
Tags
ver1 ver2
A B C D E F G
View tags
git tag –list
Push
git push --tags
Check it out
git checkout ver1
56
Stashing
master
A B C D E
View stashes
git stash list
Remove
git stash drop (clear)
58
Remotes
git push
git push
Add
git remote add <name> <url>
git remote add origin [email protected]:user/repo.git
View
git remote –v
git remote show <name>
60
Branching
strategies
Version Control with Git. DevTestOps training.
Centralized strategy
Bob’s commit
master
A B C D E F G
Eva’s commit
Alice’s commit
62
Feature-branch workflow
Small feature
master
A B C D
Large feature
63
Gitflow
65
Dictator and Lieutenants workflow
blessed
dictator
repository
lieutenant lieutenant
original
repository forked forked
repository 1 repository 2
pull request 1 pull request 2
original
developer
A B C D E F
fork 1 fork 1
developer developer
67
Inside .git folder
69
Extras
71