What is Git and GitHub – Gitting acquainted

What is Git and GitHub
Have you ever worked on a team project and found out that collaboration can be a messy affair? As the project evolves, it can be difficult to track changes. You can maintain multiple documents to keep track of various changes like my article drafts Git1, Git2, GittingItDone, etc., but is that really the most effective way to do it, especially if it’s a complex coding project? And what happens when multiple people want to work on the same code simultaneously? Wouldn’t it be amazing if each individual could work on the project without overriding each other’s work? Enter Git, a software that makes collaboration a breeze!

What is Git? 

Git is a version control software (VCS), which was created in 2005 by Linus Torvalds, the creator of Linux kernel. As a VCS, it keeps a history of all the versions of your project including line by line changes, the time of changes, and the user who made it. So, if you mess something up in your code, you can always go back to the previous version. At least your code can time travel!

Although there are many version control systems, Git dominates the field. One of the main reasons behind this is that Git is a distributed version control system (DVCS). Through this software, each developer can create their copy of the code file on their computer and work on it offline. Any changes made by them are reflected in their copy, which prevents overriding. This feature also allows multiple people to work on a project simultaneously. The changes can be merged in a file on the central server, which allows seamless collaboration. This makes Git extremely important for software development projects which has multiple collaborators working together. It ensures the smooth functioning of code by taking care of any code conflicts. Therefore, Git is an important part of every developer’s toolkit.

What are the features of Git?

Besides being a distributed version control system, Git has the following features:

1. Open source – Git is a free, open-source software. You can download Git and tailor the source code for your needs. Can it git any better? 

2. Integrity with hash algorithms – Git uses cryptographic hashes to make sure that the data you store in a file remains the same when you retrieve it later on. There’s no way that the data can be altered without Git knowing it! This alerts you to any corruption of data and is especially helpful for source code management.

3. Fast – Because Git is a distributed version control system, you do not need to be connected to a network to perform most operations. This makes Git faster than many version control softwares.

4. Efficient data storage – Git compresses data, so it does not take up as much as space as other version control systems like Subversion and CVS.

Basic Git terminology

1. Repository (repo) A repository, also called repo, is like a project consisting of a collection of files and the changes made to them. As a DVCS, Git allows developers to work on repositories locally. Any changes they make are to their own local repository. They can request for these changes to be merged in the remote repository for collaboration. This is called pushing changes.

There are various ways to work on a repo. You can create one using the git command, git init. You can also clone a remote repository and make changes to that.

2. Commit – A commit is any change that you make in your local repo and save. It’s like the ‘save’ feature in text editors. However, Git has a unique identity for each change, which is called a hash. Commits are one of the key features of Git, which help you keep track of important changes in your project.

3. Branches –
Branches refers to any time a programmer wants to diverge from a main line. For example, if a developer is working on a feature, they can write it in a separate branch before merging it into the main code.

4. Staging area – Committing a change takes place in two parts – putting the changes in the staging area followed by actually committing these changes. 

Once Git was created, it was made open for contributions from the open-source community. Many of these contributors helped in increasing the outreach of Git. In 2008, 4 programmers launched a platform to host Git repositories. This was called GitHub.

What is GitHub?

GitHub is the most popular website for hosting Git projects. With a user base of 50 million developers, it’s also a social networking site for all kinds of developers from Google to Microsoft. Although Google had its own social coding platform called Google Code, it was shut down and Google moved many of its open source projects to GitHub “to meet developers where they are”. 

You can use Git and GitHub independently. You never have to use GitHub if you are using Git. However, many Git operations are easier on the web interface.

Who wouldn’t want to work with such fun graphics?

How does GitHub work?

GitHub is built on Git, so you can do all things Git on GitHub along with other additional features.

1. Create a repository in GitHub

You can create a new repository by simply signing up and clicking on create a new repository. To add a description of your project, you can add a README file.

If you are not sure what kind of repository you want to create, then you check out the trending repositories or some popular ones. 

2. Create commits

Any changes that you make to the repo is called a commit. With each commit, you can add a description to convey its purpose. You can also view a history of your commits, and you can click on any commit to see the changes that have been made.


3. Branching

Every repo has a “main” branch by default. This should ideally contain your main code.

4.Fork a repository

If you come across a public repository that catches your eye, and you want to make changes to it but aren’t quite sure about the changes yet, you can create a copy of it in your account. This is called forking and can be done by clicking on the ‘fork’ button.

Once you have made the changes and are convinced that they can help the original repo owner, you can send them a request to add your code to the main repo. This is called a pull request.

5. Resolve conflicts

When multiple people are collaborating on a project, conflicts can arise. For example, if two programmers have made changes to the same line of code, then the repo owner needs to decide which change they want to go with.

6. Clone repo to Git and push/pull changes

You can copy a remote repository on your machine by ‘cloning’ it. You can then work on it locally through Git.

7. Post issues

Issues are like comments on a particular project. You can use this to suggest changes to the project or ask questions among other things.

8. Host a static website

You can use GitHub pages to create one free website with each account. This is an exclusive feature on GitHub, which is not present on Git.

How to learn Git and GitHub?

Now that you know why Git and GitHub are important, let’s find out about how to learn them. 

If you want to dabble in Git and GitHub before committing to learning it, then you can check GitHub’s guides.You can also make use of Stack Overflow for any queries that you may have. 

If you are all jazzed up about learning Git, then you can check out Internshala’s Git training and git going! (we don’t use so many puns there in case you are worried). This training has been designed especially for beginners and will help you master the basics with your own project! You can use BLOG10 to get a discount of 10%.

Image credits: https://icon-icons.com/icon/file-type-git/130581


Leave a Reply

Your email address will not be published. Required fields are marked *