GitHub - Version Control System
About Version Control
What is “version control,” and why should you care? 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. For the examples in this book, you will use software source code as the files being version controlled, though in reality, you can do this with nearly any type of file on a computer. If you are a graphic or web designer and want to keep every version of an image or layout (which you would most certainly want to), a Version Control System (VCS) is a very wise thing to use. It allows you to revert files to a previous state, revert the entire project to a previous state, compare changes over time, see who last modified something that might be causing a problem, who introduced an issue and when, and more. Using a VCS also generally means that if you screw things up or lose files, you can easily recover. In addition, you get all this for very little overhead.
Distributed Version Control System
A centralized version control system (CVCS) uses a central
server to store all files and enables team collaboration. But the major
drawback of CVCS is its single point of failure, i.e., failure of the central
server. Unfortunately, if the central server goes down for an hour, then during
that hour, no one can collaborate at all. And even in the worst-case, if the disk
of the central server gets corrupted and proper backup has not been taken, then
you will lose the entire history of the project. Here, distributed version
control system (DVCS) comes into the picture.
DVCS clients not only check out the latest snapshot of the directory but also fully mirror the repository. If the server goes down, then the repository from any client can be copied back to the server to restore it. Every checkout is a full backup of the repository. Git does not rely on the central server and that is why you can perform many operations when you are offline. You can commit changes, create branches, view logs, and perform other operations when you are offline. You require a network connection only to publish your changes and take the latest changes.
A Short History of Git
As with many great things in life, Git began with a bit of
creative destruction and fiery controversy. The Linux kernel is an open-source
software project of fairly large scope. For most of the lifetime 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 (and in particular Linus
Torvalds, the creator of Linux) to develop their own tool based on some of the
lessons they learned while using BitKeeper. Some of the goals of the new system
were as follows:
• Speed
• Simple design
• Strong support for non-linear development (thousands of
parallel branches)
• Fully distributed
• Able to handle large projects like the Linux kernel efficiently
(speed and data size)
Since its birth in 2005, Git has evolved and matured to be easy to use and yet retain these initial qualities. It’s incredibly fast, it’s very efficient with large projects, and it has an incredible branching system for non-linear development
Advantages of Git
Free and open source
Git is released under GPL’s open source license. It is
available freely over the internet. You can use Git to manage property projects
without paying a single penny. As it is open-source, you can download its
source code and also perform changes according to your requirements.
Fast and small
As most of the operations are performed locally, it gives a
huge benefit in terms of speed. Git does not rely on the central server; that
is why there is no need to interact with the remote server for every operation.
The core part of Git is written in C, which avoids runtime overheads associated
with other high-level languages. Though Git mirrors the entire repository, the size
of the data on the client-side is small. This illustrates the efficiency of Git
at compressing and storing data on the client-side.
Implicit backup
The chances of losing data are very rare when there are
multiple copies of it. Data present on any client-side mirrors the repository,
hence it can be used in the event of a crash or disk corruption.
Security
Git uses a common cryptographic hash function called secure
hash function (SHA1), to name and identify objects within its database. Every
file and commit is check-summed and retrieved by its checksum at the time of
checkout. It implies that it is impossible to change files, dates, and commit
messages and any other data from the Git database without knowing Git.
No need for powerful
hardware
In the case of CVCS, the central server needs to be powerful
enough to serve the requests of the entire team. For smaller teams, it is not an
issue, but as the team size grows, the hardware limitations of the server can
be a performance bottleneck. In the case of DVCS, developers don’t interact with
the server unless they need to push or pull changes. All the heavy lifting happens
on the client-side, so the server hardware can be very simple indeed.
Easier branching
CVCS uses a cheap copy mechanism, If we create a new branch,
it will copy all the codes to the new branch, so it is time-consuming and not
efficient. Also, deletion and merging of branches in CVCS is complicated and
time-consuming. But branch management with Git is very simple. It takes only a
few seconds to create, delete, and merge branches.
Git Basic Commands List
1) ADD User name and email
git config –global user.name
git config –global user.email
2) Git initialize command
git init
3)Git add file
git add index.html
git add .
4)To check the status
git status
5) To remove the file from stage
git rm --cached index.html
6) To display all commits
git log
7) To add the commit
git commit -m “Fixed”
8) ALL the commits
git log –oneline
9)Checkout command
git checkout <unique key>
git checkout master
10) git revert <unique key>
git reset <unique key>
11) All the branches
git branch –a
12)Create a branch
git branch <branch name>
13) Switched to the branches
git checkout <branchName>
14) To delete the branch
git branch -D <branchName>
15) Create a branch and checkout it
git checkout -b <branchName>
16) Merge branch to the master
git merge <branch name>
Comments
Post a Comment