GIT | An Introduction to Github

 

Nowadays software development takes place in a distributive way. This article focuses on one such technology that supports distributed software development i.e GIT.

What GIT is about?

  • 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.
  • Git relies on the basis of distributed development of a software where more than one developer may have access to the source code of a specific application and can modify changes to it which may be seen by other developers..
  • Initially designed and developed by Linus Torvalds for Linux kernel development in 2005.
  • Every git working directory is a full-fledged repository with complete history and full version-tracking capabilities, independent of network access or a central server.
  • Git allows a team of people to work together, all using the same files. And it helps the team cope up with the confusion that tends to happen when multiple people are editing the same files.

Why Use Version Control Software?

  • Version control software allows the user to have “versions” of a project, which show the changes that were made to the code over time, and allows the user to backtrack if necessary and undo those changes.
  • This ability alone – of being able to compare two versions or reverse changes, makes it fairly invaluable when working on larger projects.
  • In a version control system, the changes would be saved just in time – a patch file that could be applied to one version, in order to make it the same as the next version.
  • All versions are stored on a central server, and individual developers checkout and upload changes back to this server.

 Characteristics of Git

  1. Strong support for non-linear development
  • Git supports rapid branching and merging, and includes specific tools for visualizing and navigating a non-linear development history.
  • A major assumption in Git is that a change will be merged more often than it is written.
  • Branches in Git are very lightweight.
  1. Distributed development
  •  Git provides each developer a local copy of the entire development history, and changes are copied from one such repository to another.
  • The changes can be merged in the same way as a locally developed branch very efficiently and effectively.
  1. Compatibility with existing systems/protocol
  •  Git has a CVS server emulation, which enables the use of existing CVS clients and IDE plugins to access Git repositories.

    4.  Efficient handling of large projects

  •  Git is very fast and scalable compared to other version control systems.
  • The fetching power from a local repository is much faster than what possible with remote server.
  1. Data Assurance
  •  The Git history is stored in such a way that the ID of a particular version depends upon the complete development history leading up to that commit.
  • Once published, it is not possible to change the old versions without it being noticed.
  1. Automatic Garbage Collection
  •  Git automatically performs garbage collection when enough loose objects have been created in the repository.
  • Garbage collection can be called explicitly using git gc –prune.
  1. Periodic explicit object packing
  •  Git stores each newly created object as a separate file. It uses packs that store a large number of objects in a single file (or network byte stream) called packfile, delta-compressed among themselves.
  • A corresponding index file is created for each pack file, specifying the offset of each object in the packfile.
  • The process of packing can be very expensive computationally.
  • Git allows the expensive pack operation to be deferred until later when time does not matter.
  • Git does periodic repacking automatically but manual repacking can be done with the git gc command.

How GIT Works

  1. A Git repository is a key-value object store where all objects are indexed by their SHA-1 hash value.
  2. All commits, files, tags and filesystem tree nodes are different types of objects living in this repository.
  3. A Git repository is a large hash table with no provision made for hash collisions.
  4. Git specifically works by taking “snapshots” of files

Creating a GitHub Account:

  1. Go to github.com and enter the required user credentials asked on the site and then click on SignUp for GitHub button.

2

      2. Choose a plan that best suits you. The following plans are available:-

3Then Click on Finish Sign Up.

The account has been created. The user is automatically redirected to your Dashboard.

4

  1. Creating a new Repository
    1. Login to your Git Hub account
    1. On the dashboard click on the Green Button stating New repository.
    1. Make sure to verify the Git hub account by going into the mail which was provided when creating the account.
    2. Once verification has been done, the following screen comes

    5

5. Start by giving a repository name, description(optional) and select the visibility and accessibility               mode for the repository

 6. Click on Create repository

7. The repository (in this case ITE-304 is the repository) is now created. Repository can be created

6

Uploading existing file to GitHub

  1. The system should have git installed in it. For installing git please refer https://git-scm.com/downloads. Make sure to choose Run git from Windows Command prompt option during installation. Otherwise open git bash in place of step 2.
  2. Open Terminal (for Mac users) or the command prompt (for Windows and Linux users).
  1. Change the current working directory to your local project
  2. Initialize the local directory as a git repository in different ways as described in the image.

g1

A new .git folder is created in the directory which is by default hidden.

Add the files in your new local repository. This stages them for the first commit.

g2

Commit the files that you’ve staged in your local repository.

g3

 

At the top of the GitHub repository’s Quick Setup page, click on the icon shown and copy the remote repository URL.

7

In the Command prompt,add the URL for the remote repository where your local repository will be pushed.g4

g5

Push the changes in your local repository to GitHub.

g6And here you go…

8

Git Commands

  1. An Ultimate Guide to Git and Github
  2. List of useful Github Commands

Companies and Projects Using GIT

  • The reputed and dream job companies of all the geeks like Microsoft, Google, Facebook , Twitter, LinkedIn, Netflix make use of GIT.
  • Open source projects like: Ruby On Rails, jQuery, Perl, Debian, the Linux Kernel and many more make use of git.

Tutorials for learning Git in depth:

  1. https://www.atlassian.com/git/tutorials/
  2. http://www.vogella.com/tutorials/Git/article.html
  3. http://www.tutorialspoint.com/git/
  4. https://www.youtube.com/watch?v=Kp5BSBoOw8k
  5. https://try.github.io/levels/1/challenges/1

References

http://www.tutorialspoint.com/git/

http://git-scm.com/docs/gittutorial

https://www.atlassian.com/git/tutorials/

Article By Mudit Maheshwari:mudit

A 3rd year B.Tech IT student from VIT University, Vellore having keen interest in coding , learning about new technology and developing softwares . Besides being passionate about coding, he also loves playing guitar and singing. Currently staying in Chennai. You can reach him at mudit94@gmail.com.

If you also wish to showcase your blog here,please see GBlog for guest blog writing on GeeksforGeeks.

 



My Personal Notes arrow_drop_up


Article Tags :

2


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.