Professional Documents
Culture Documents
DevOps Chapter 2
DevOps Chapter 2
DevOps Chapter 2
DevOps
IT-41
DevOps
Chapter-2
Version Control System: The code which is stored in Git keeps changing as more code is added.
Also, many developers can add code in parallel. So Version Control System is a software helps in
handling this by maintaining a history of what changes have happened.
• Centralized version control systems, have a single “central” copy of your project on a server .
• It commit changes to this central copy.
• You can pull the files that you need, but you never have a full copy of your project locally.
• Some of the most common version control systems are centralized, including Subversion
(SVN) and Perforce.
Types of Version Control
• In distributed version control systems (DVCS), we don‘t rely on a central server to store all the
versions of a project’s files.
• Instead, we clone a copy of a repository locally so that you have the full history of the project.
• Two common distributed version control systems are Git and Mercurial.
Difference between CVCS and DVCS
CVCS DVCS
CVCS is dependent on the access to the server DVCS provides the benefits to work offline
CVCS is easy to administrate and has more CVCS is difficult to administrate
control over users and access
CVCS is comparatively slow as you have to DVCS is comparatively fast as you don’t have to
contact the central server for every command. contact the central server for every command.
CVCS allows you to checkout only few lines of Downloading the entire history can take an
code if you just need to work on few modules. unreasonable amount of time and disk space in
DVCS
SVN and CVS are the popular tools of CVCS GIT and Mercurial are the popular tools of
DVCS
History of Gits
• During the early years of the Linux kernel maintenance (1991–2002), changes to the software
were passed around as patches and archived files.
• In 2002, the Linux kernel project began using a proprietary DVCS called BitKeeper.
• In 2005, the relationship between the community that developed the Linux kernel and the
commercial company that developed BitKeeper broke down, and the tool’s free-of-charge
status was revoked.
• This prompted the Linux development community to develop their own tool based on some of
the lessons they learned while using BitKeeper.
• Since its birth in 2005, Git has evolved and matured to be easy to use and yet retain these
initial qualities.
Characteristics of Git
Working Directory and staging area: The working directory is the place where files are checked
out And Staging area stores modified files
Suppose you modified two files, namely “sort.c” and “search.c” and you want two different
commits for each operation. You can add one file in the staging area and do commit. After the
first commit, repeat the same procedure for another file.
Trees
• Tree is an object, which represents a directory.
• It holds blobs as well as other sub-directories.
• A tree is a binary file that stores references to blobs.
Commits
• Commit holds the current state of the repository.
• You can consider a commit object as a node of the linked list.
• Every commit object has a pointer to the parent commit object.
• From a given commit, you can traverse back by looking at the parent pointer to view the
history of the commit.
• If a commit has multiple parent commits, then that particular commit has been created by
merging two branches.
Tags
• Tag assigns a meaningful name with a specific version in the repository.
• Tags are very similar to branches, but the difference is that tags are immutable.
• It means, tag is a branch, which nobody intends to modify.
• Once a tag is created for a particular commit, even if you create a new commit, it will not be
updated.
• Usually, developers create tags for product releases.
Clone
• Clone operation creates the instance of the repository.
• Clone operation not only checks out the working copy, but it also mirrors the complete
repository.
• Users can perform many operations with this local repository.
• The only time networking gets involved is when the repository instances are being
synchronized.
Basics of Git
Pull
• Pull operation copies the changes from a remote repository instance to a local one.
• The pull operation is used for synchronization between two repository instances.
• This is same as the update operation in Subversion.
Push
• Push operation copies changes from a local repository instance to a remote one.
• This is used to store the changes permanently into the Git repository.
• This is same as the commit operation in Subversion.
HEAD
• HEAD is a pointer, which always points to the latest commit in the branch.
• Whenever you make a commit, HEAD is updated with the latest commit.
• The heads of the branches are stored in .git/refs/heads/ directory.
Revision
• Revision represents the version of the source code.
• Revisions in Git are represented by commits.
• These commits are identified by SHA1 secure hashes.
URL
• URL represents the location of the Git repository.
• Git URL is stored in config file.
Git Commandline
There are a lot of different ways to use Git. E.g. original command-line tools and graphical user
interfaces of varying capabilities.
The command line is the only place you can run all Git commands.
Most of the GUIs implement only a partial subset of Git functionality for simplicity.
Git Commands
git config, git init, git clone, git add, git commit, git diff, git reset, git status, git rm
git log, git show, git tag, git branch, git checkout, git merge, git remote, git push, git pull
git stash
Git Commands
git config: This command sets the author name and email address respectively to be used with your commits.
git clone: This command is used to obtain a repository from an existing URL.
Usage: git clone [url]
Git Commands
git add: This command adds a file to the staging area.
git commit
Usage: git commit -m “[ Type in the commit message]”
This command records or snapshots the file permanently in the version history.
Git Commands
git diff
Usage: git diff
This command shows the file differences which are not yet staged.
Git Commands
git reset
Usage: git reset [file]
This command unstages the file, but it preserves the file contents.
git status
Usage: git status
This command lists all the files that have to be committed.
git rm
Usage: git rm [file]
This command deletes the file from your working directory and stages the deletion.
Git Commands
git log
Usage: git log
This command is used to list the version history for the current branch.
Git Commands
git show
Usage: git show [commit]
This command shows the metadata and content changes of the specified commit.
Git Commands
git tag
Usage: git tag [commitID]
This command is used to give tags to the specified commit.
git branch
Usage: git branch
This command lists all the local branches in the current repository.
git checkout
Usage: git checkout [branch name]
This command is used to switch from one branch to another.
git merge
Usage: git merge [branch name]
This command merges the specified branch’s history into the current branch.
git remote
Usage: git remote add [variable name] [Remote Server Link]
This command is used to connect your local repository to the remote server.
git push
Usage: git push [variable name] master
This command sends the committed changes of master branch to your remote repository.
Git Commands
git stash
Usage: git stash save
This command temporarily stores all the modified tracked files.
• https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
• https://git-scm.com/book/en/v2/Getting-Started-A-Short-History-of-Git
• https://www.geeksforgeeks.org/history-of-git/
• https://devopsbuzz.com/centralized-vs-distributed-version-control-systems/#:~:tex
t=CVCS%20is%20dependent%20on%20the,is%20server%20from%20one%20place
.
• https://support.atlassian.com/bitbucket-cloud/docs/types-of-version-control/
• https://www.tutorialspoint.com/git/git_basic_concepts.htm
Thank You