GIT Commands.

Introduction to GIT

I had a GIT workshop in FOSS club and therefore, this post is going to be on GIT.This workshop was very important to us to understand about GIT. After that workshop I got an idea about what GIT is and for what purpose we use GIT. I hope that after going through this post you will get an idea about GIT.

What is GIT ?

It’s definition is “GIT is a free and open source distributed Version Control System designed to handle everything from small to very large projects with speed and efficiency.”

Before going into that you have to know about Version Control System (VCS). A version control system (also known as a Revision Control System) is a repository of files, often the files for the source code of computer programs, with monitored access. The are of three types as following :

  • Local Version Control Systems – Many people’s version-control method of choice is to copy files into another directory (perhaps a time-stamped directory, if they’re clever). This approach is very common because it is so simple, but it is also incredibly error prone. It is easy to forget which directory you’re in and accidentally write to the wrong file or copy over files you don’t mean to.To deal with this issue, programmers long ago developed local VCSs that had a simple database that kept all the changes to files under revision control.
  • Centralized Version Control Systems – The next major issue that people encounter is that they need to collaborate with developers on other systems. To deal with this problem, Centralized Version Control Systems (CVCSs) were developed. These systems, such as CVS, Subversion, and Perforce, have a single server that contains all the versioned files, and a number of clients that check out files from that central place. For many years, this has been the standard for version control.
  • Distributed Version Control Systems – This is where Distributed Version Control Systems (DVCSs) step in. In a DVCS (such as Git, Mercurial, Bazaar or Darcs), clients don’t just check out the latest snapshot of the files: they fully mirror the repository. Thus if any server dies, and these systems were collaborating via it, any of the client repositories can be copied back up to the server to restore it. Every clone is really a full backup of all the data.

How to install GIT ?

Installing GIT is very easy. The thing is that you need few codes which is to be given in your terminal (for linux users). Others can directly install GIT through the link given –http://git-scm.com.

Creating a repositories

Repository commonly refers to a storage location, often for safety or preservation.Inside a repository we can store n number of folder.It is very important to create a repository so that you can save all your work in a single directory. To create a repository we have a code git init <name of repository>. This will initialize a repository of any given name. You too can do it, just open your terminal and type this code.

Cloning a GIT repository

When you create a repository on GitHub, it exists as a remote repository. You can create a local clone of your repository on your computer and sync between the two locations. This will create a local repository in which you can edit anything you want to contribute. For cloning a repository you just have to type git clone , and then paste the URL of the location where your main repository is currently saved. Press Enter. Your local clone will be created. git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY Cloning. Then it will unpack those files which were saved repository.

How to do changes in a repository ?

Making changes in your repository is not a difficult task. You have to remember few codes to add new changes you made. Few of the functions are

git add <type the name of your file> – This command updates the index using the current content found in the working tree, to prepare the content staged for the next commit. After doing add function it will show the difference between the work before you added and after you added.

git commit -m “<type any commitment you did in the file>” – This command Stores the current contents of the index in a new commit along with a log message from the user describing the changes.

git diff <type the name of your file> – This command will show the difference between the work before you added and after you added.

git push  – This command is used to push your edited file to the main branch.This will upload all the changes you made.

git pull <type name of your repository><type name of main branch> – Generally in GIT we need to push a file as the topmost file. Your files will be pushed only if your have all other new changes that your teammates had done. If you don’t have then first pull those file from the main branches and then push the file which you have updated.

git status – This command is used to check your status that where are you now and what all changes you had done in your repository.

git checkout<branch name> – This command updates files in the working tree to match the version in the index or the specified tree.

git head – This command is also same as status command. The only thing is that this will show us our current status what we had done.

git show – This command will show us that what all commits we have done.

How it is useful ?

  • We can edit any repository more faster and it is more reliable
  • No limitations for adding files and creating repository.
  • Free open source for all.
  • We can do editing work for days. No worry about time.
  • Easy to work by doing a local cloning of the repository.

This blog was to give you an idea about GIT. Now it’s your turn to do it practically.Try Github.com .

 

 

 

A community needs a soul if it is to become a true home for human beings. You, the people must GIT it this soul.

 

 

 

 

 

Source : https://git-scm.com/