Centralised Version Controlling
Centralised Version Controlling
Version Controlling
This is the process of maintaining multiple versions of the code All the team members upload their
code(check in) into the remote version controlling system. The VCS accepts the code uploads from
multiple team members and integrates it so that when the other team members download the code,
they will be able to see the entire work down by the team VCS's also preserve older and later versions of
the code so that at any time we can switch between whichever version we want
Here we have a remote server(code repository) into which all the team members check in the code and
all the features of version controlling are implemented in this remote server
Here we have a local repository installed on every team member machines where version controlling
happens at the level of individual team members form where it is uploaded into a remote server where
version controlling happens for the entire team
2 Install it
1|Page
GIT Madhav
2 Install git
sudo apt-get install -y git
Working directory is the location where all the code is created Initially all the files present here are called as
untracked files
Staging area is the location where file indexing happens and it is the buffer area of git and the files are called
as indexed files
Local repository is where version controlling happens and the files are called as committed files
Branching in Git
This is a feature of git using which we can create separate branches for different functionalities and later
merge them with the main branch also known as the master branch. This will help in creating the code in
an uncluttered way
3 To create a branch
git branch branch_name
2|Page
GIT Madhav
6 To merge a branch
git merge branch_name
Note: Whenever a branch is created whatever is the commit history of the parent branch will be
copied into the new branch
Note: Irrespective of, on which branch a file is created or modified git only considers form which branch
it is committed and the file belongs to that committed branch only.
This is the remote repository into which the code is uploaded and this process is called as check-in
3|Page
GIT Madhav
Git clone
This will download all the code from the remote repository into the local repository and it is generally
used only once when all the team members want a copy of the same code
Git fetch
This will download only the modified files but it will place them on a separate branch called as "remote
branch”, we can go into this remote branch check if the modifications are acceptable and then merge it
with the main branch
Git pull
This will download only the modified files and merge them with
our local branches
1 Open the GitHub
2 Go to the repository that we uploaded
3 Select a file and edit it--->Click on commit changes
4 Open git bash
5 git pull
We can see the modified files on the main branch
4|Page
GIT Madhav
Git Merge
5|Page
GIT Madhav
Git rebase
This is called as fast forward merge where the commits coming from a branch are projected as the top
most commits on master branch
This is used to selectively pick up certain commits and add them to the master branch
Git reset
This is a command of git using which we can toggle between multiple versions of git and access
whichever version we want
Reset can be done in 3 ways
1 Hard reset
2 soft reset
3 Mixed reset
In hard reset HEAD simply points to an older commit and we can see the
data as present at the time of that older commit
6|Page
GIT Madhav
Git reset
This is a command of git using which we can toggle between multiple versions of git and access
whichever version we want
Reset can be done in 3 ways
1 Hard reset
2 soft reset
3 Mixed reset
Hard reset HEAD simply points to an older commit and we can see the data as present at the time of
that older commit
Soft reset will also move the head to an older commit but we will see the condition of the git repository as
just one step prior to the c commit ie the files will be seen in the staging area
Mixed reset also moves the head to an older commit but we will see the condition of git as 2 steps prior
to the c commit ie the files will be present in the untracked/modified section
Stash is a section of git into which once the files are pushed
git cannot access them
To stash all files, present in staging area, untracked section and .gitignore
git stash -a
7|Page
GIT Madhav
Git squash
This is the process of merging multiple commits and making it look like a single commit. This can be done
using the git rebase
Command
2 To squash
git rebase -i HEAD~5
This will open the top 5 commits in vi editor for which ever commits we want to perform a squash
operation remove the word "pick" and replace it with "squash"
8|Page