3 - Version Control System.
Speck Academy 2021
About VCS
Categories of VCS
GIT basics
GIT branching
GIT merging
Gitflow workflow
1
2
3
4
5
6
Overview
1
About VCS
About VCS
Version Control System - VCS
Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later.
By using version control systems, unlimited number of developers can work on the same code base.
VCS allows you to:
2
Categories of VCS
Categories of VCS
Centralized Version Control Systems - single server that contains all the versioned files, and a number of clients that check out files from that central place.
Distributed Version Control System - Compared to CVCs, clients don’t just check out latest snapshot of the files, rather, they fully mirror the repository, including its full history.
Categories of VCS
Repository
Working copy
Working copy
Centralized VCS
Workstation #1
Workstation #2
Commit / Update
Repository
Repository
Repository
Distributed VCS
Push / Pull
Commit / Update
Working copy
Workstation #1
Working copy
Workstation #2
Advantages of DVCS
Performing actions other than pushing and pulling changesets is extremely fast because the tool only needs to access the hard drive, not a remote server.
Commiting new changesets can be done locally without anyone else seeing them. Once you have a group of changesets ready, you can push all of them at once.
3
GIT basics
GIT basics overview
Jargon
History
About GIT
GIT snapshots
The three states
Essential commands
Jargon
In order to understand GIT we will use some specific terms:
History
Created by Linux development community in 2005 after the collaboration of the Linux community with BitKeeper was broken.
Some of the Goals:
About GIT
GIT is most widely used modern version control system in the world.
Major difference between GIT and any other VCS is the way GIT thinks about its data.
The others systems (CVS, Subversion, Bazaar...) think of the information they store as a set of files and the changes made to each file over time (delta-based version control).
GIT thinks of its data more like a series of snapshots of a miniature filesystem.
Essential commands
List of essential commands:
GIT snapshots
Version 1
A
B
C
Version 2
A1
B
C1
Version 3
A1
B
C2
Version 4
A2
B1
C2
Version 5
A2
B2
C3
GIT snapshots
What is actually happening?
Each time we run git commit, new snapshot of whole filesystem is being created.
After that, GIT automatically creates packfile whose content is compressed and delta encoded.
So in fact, GIT also saves diffs to files but the way it does it’s different from other VCS.
The three states
Modified means that you have changed the file but have not committed it to your database yet.
Staged means that you have marked a modified file in its current version to go to your next commit snapshot.
Commited means that the data is safely stored in your local database.
The three states / Modified
Git directory (repository)
Working directory
Staging area
You modify files in your working directory.
The three states / Staged
Git directory (repository)
Working directory
Staging area
You stage the files, adding snapshots of them to your staging area.
Stage files
The three states / Committed
Git directory (repository)
Working directory
Staging area
You do a commit that stores snapshot permanently to your Git directory.
commit
stage files
The three states / Checkout
Git directory (repository)
Working directory
Staging area
You do a commit that stores snapshot permanently to your Git directory.
stage files
Checkout the project
commit
4
GIT branching
GIT branching
Branching means you diverge from the main line of development and continue to do work without messing with that main line.
Branches are used to develop features isolated from each other.
The way GIT branches is incredibly lightweight, making branching operations nearly instantaneous, and switching back and forth between branches generally just as fast.
Default branch is master.
A branch is not available to others unless you push the branch to your remote repository.
GIT branching
Useful commands:
Origin is a default name given to the original remote repository that you clone, from where you want to pull and push changes.
5
GIT merging
GIT merging 1/3
In order to explain merging try to understand following scenario:
GIT merging 2/3
What just happened?
GIT merging 3/3
Merge conflict:
6
Gitflow workflow
Gitflow workflow
The Gitflow workflow defines a strict branching model designed around the project release.
The overall flow:
Gitflow workflow / master & develop
The master branch stores the official release history, and the develop branch serves as an integration branch for features.
Master
Develop
v0.1
v0.2
v1.0
Gitflow workflow / feature
Each new feature should reside in its own branch. Feature branches use develop as their parent branch.
Master
Develop
v0.1
v0.2
v1.0
Feature
Feature
Gitflow workflow / release
Created once develop has acquired enough features for release. No new features can be added after this point, except bug fixes and documentation.
Master
Develop
v0.1
v0.2
v1.0
Feature
Feature
Release
Gitflow workflow / hotfix
Maintenance or hotfix branches are used to quickly patch production releases.
Master
Develop
v0.1
v0.2
v1.0
Feature
Feature
Hotfix
Release
7
Hands-on
Hands-on
8
Homework
Homework