Thursday, 17 September 2015

Git Version Control System: An Introduction

Git is a free and open source Version Control System (VCS) aimed at providing a way to manage various versions of a software and to keep a track of changes made in each version. Putting it in simple words, suppose you start working on a particular piece of code and frequently make changes to it. Now, the traditional way to take care of these changes and maintaining the original code is by making copies of it. So, you keep a backup copy, make changes to the spare copy of files you made, and if all works well, you introduce the changes in your main program. All this can be done more efficiently by git, which keeps a track of all this stuff, such as when did you make changes to a file, what were the changes etc. It is another useful piece of code written by Linus Torvalds, the man behind Linux. :)

Github.com is a famous repository hosting website, where you can share your git repositories with other people around the globe. By default, your code can freely be viewed by anyone across the globe, which is a really useful thing if you want to keep your project "open source" and want other people to contribute to it. However, if you have a paid account, you can keep your code hidden and available only to specific people whom you authorize to do so. Overall, it is a great tool, both for small softwares and also for gigantic programs.

Here, we present a tutorial that uses some of the most basic commands used in git.

=>First of all, install git by typing the following command inside your terminal:

sudo apt-get install git

=> git init

Typing this will initialise git and create a hidden folder named ".git" inside your current folder.

git

=>git add file.txt
And then:
git commit

This will "commit" whatever changes you made to file.txt. A COMMIT_EDITMSG file opens up. Type the description of the changes made and press Ctrl+O.

git

=>If you change a file's contents and then type git status, it will warn you that changes are not yet committed.

=>Type git log to see the description of all the changes you committed.

git

=>To revert/go back to a change you made, type :

git revert

where hash of the commit is the long numeric value written with each commit.

To know more, you can check out this great, interactive beginners tutorial on https://try.github.io/.

No comments:

Post a Comment