You are on page 1of 17

VCS and Processes

Little bit of information about development processes.


Why we should use git?
Code distribution.

Branches.

Pull requests/Merge.

Commits.

Rollbacks.

Stashes.

Work with remote.


Code distribution.
Developer B

Branch Local Branch


A repository B

Developer D
Branch
Branch

A
B

Server

repository
repository

Local
Local

Branch Remote Branch


A repository B
Developer C

Branch
Branch

B
A

Developer A

Branch Local Branch


A repository B
Branches.

Branch B
C1 C2 C3 C4

Branch A
C1 C2 C3 C4 C5 C6

Master
C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11

Branch C
C1 C2 C3 C4 C5 C6
Pull requests/Merge.

Code review (comments).


Branch B
Comments resolving.
C1 C2 C3
Approving.

Branch A Merge.
C1 C2 C3 C4 C5 C6

Master
PR
C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 C12

PR
Branch C
C1 C2 C3 C4 C5 C6
Commits.

File 1 File 1 File 1


+3 lines +3 lines
+3 lines
-2 lines -2 lines
-2 lines

Git add . Git commit.


File 2 File 2 File 2

new file
new file new file
Commits.

Branch b
Branch a

Me
erg

Branch b
Resolving
Conflict
Stash.

File 1 File 1

Working directory
+3 lines +3 lines
-2 lines -2 lines

clean
Git add . Git stash
File 2 File 2

new file new file


Stash.

File 1
Stash
File 1 +3 lines
-2 lines
+3 lines
-2 lines

stash@{0}: WIP on master:


6dd0a6b Merge branch 'test-b'
Git stash apply
File 2
File 2
new file

new file
C1
Commit message 1 Hash 1
Git log.

C2
Commit message 2 Hash 2

C3
Commit message 3 Hash 3
C4

Commit message 4 Hash 4


C5

Commit message 5 Hash 5


C6

Commit message 6 Hash 6


C7

Commit message 7 Hash 7


C8

Commit message 8 Hash 8


C1
Commit message 1 Hash 1

C2
Commit message 2 Hash 2

C3
Commit message 3 Hash 3
Git reset.

C4
Commit message 4 Hash 4
C5

Commit message 5 Hash 5


Git reset hash 3
C1

Commit message 1 Hash 1


C2

Commit message 2 Hash 2


C3

Commit message 3 Hash 3


Reset types.

—soft —mixed —hard

C1 C2 C3 C1 C2 C3 C1 C2 C3

C1 C2 C1 C2 C1 C2
Work with remote.
Remote repository

Branch
A

Git clone https://repo-url.com/your-repo.git

Local repository

Branch
A
Work with remote.
Remote repository

Branch Branch Branch Branch


A B c d

Git fetch

Local repository

Branch Branch
A B
Work with remote.
Remote repository

Branch Branch Branch Branch


A B c d

Local repository

Branch Branch Branch Branch


A B c d
Work with remote.
Remote repository

Branch Branch Branch Branch Branch


A B c d A
R1 R3

Git pull = git fetch + git merge | git push

Local repository

Branch Branch Branch Branch Branch


A B c d A
R2 R3
Common git commands.
git init

git clone <repo url>

git add <file.name>/add .

git commit -m “commit message”

git reset <commit hash> —hard/ —soft/ —mixed

git stash / stash save “stash name”

git stash apply / apply@{0} - stash name

git fetch

git pull

git push

git cherry-pick <commit hash>

You might also like