Why And How You Should Start Using Git & Github Right Now!!

Hemant Jain
Code Dementia
Published in
7 min readFeb 19, 2019

If you have been programming for a while you must have heard someone saying:

“You can get all my code from Github.

“Upload your work on Github and showcase it to the world!”

“You should have a Github Profile to show your work to prospective employers.”

“If you want to contribute to Open Source you need to know Git and Github!”(GSOC Vibes!)

So what is all the rage about Git And Github?

Let’s start with what happens when you build a decent size project and NOT use a version control system like Git.

One of the first web apps I ever made was using ruby on rails. It started off as a small project but as I started adding more and more features, the codebase started growing and more importantly changing. I was breaking and rebuilding stuff on a constant basis. It started taking me a lot of time to revert back or to make changes as I had to look out at the interconnected parts of the code as I was making changes to the same files and folders again and again.

I had a moment of (stupid) epiphany and started copying and making new folders of the same code with different names(not even giving a version number). Initially, it turned out to be okay but as I made more and more changes the names of the folders grew longer and I started to forget the changes I made in a certain folder(Documentation at that point was an alien term to me!). It started becoming a mess at one point and I had to ditch the project!

I don’t remember how exactly they were named but were somewhat like this.

What is Git?

Here is how Git’s official site defines it in the first line:

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.

Version-Control System is a program that allows you to track every minute change you make to your code. It helps you to track your code over time.

But why does tracking code over time help us?

Because it provides a lot of benefits:

  1. It helps you to make several versions of your code based on the time you created or modified it.
  2. These versions can be used to revert back to any state of the code at a particular point in time. It’s like going back in time to any point since the inception of the code. This helps you immensely when some change in your code breaks the whole app. You can simply go back in time and serve the old code which actually works!
  3. Every change in your code is accompanied by something called a commit which is basically a message telling what change has been produced in that particular version. A commit acts like a checkpoint in a game for your code (You can come back to it anytime in the future). This makes it very easy to isolate problems and bugs and fix them and describes each and every change very precisely.
  4. Version control systems maintain a history which stores all the changes to the code with the timestamp they were made on along with the commits. It doesn’t make separate folders for each change and hence saves you from the above multiple folder hell which you can end up upon!

What benefit does the distributed portion bring?

  1. When multiple people are working on the same piece of code they can make changes and commits and sync it to the same folder.
  2. Hence, The system allows you to track the work of each individual contributor and makes working in teams on the same piece of code a bliss.
  3. Each contributor can work on different features without disturbing each other’s code and add it back to the main code by using various built-in mechanisms in Git.

What is Github And Why Do We Need It?

Github is a cloud-based hosting service that allows you to sync your code and Git history on a cloud server to the almighty Internet.

When we have Git then why do we need Github?

Because Git though being distributed, It can only sync over a local network on its own. Hence Github allows us to perform the same Git operations on the internet and helps us to work with people around the globe spread over large teams. It acts as a central repository(A complicated term for a folder!) and allows people to push(upload) and pull(download) various changes in the repository.

Benefits Of Github:

  1. Github stores and helps you to showcase your work to the programming community.
  2. Github provides you with a visual representation of how many people are contributing to the code and how actively the contributions are being done.
  3. Github is being used for most of the major open source projects. If you intend to contribute to open source then learning Git is a necessity.
  4. Many companies in the tech space give major consideration to your Github profile to gauge how actively you have been doing development work.

How to get Started With Git And Github?

  1. Download Git Setup from this URL: https://git-scm.com/download
  2. Install using the default configurations.
  3. Create An Account On https://github.com/
  4. Log in To Your Github and complete the verification.
  5. Click The + Button and Click New Repository.

6. Give a name and description to the repository and choose public and click Create Repository.

7. Now go to a folder on your system where you want to clone the repository you made on Github and right click and select Git Bash Here.

8. You need to make some configurations in git before you get started. Enter the command in Git bash terminal.

then,

9. Now copy the cloning URL from here

10. And run the command

git clone URL

where URL is the URL that you copied.

11. Go inside the folder that has just been created using cd command

12. Create a new text file inside the folder and write something random in the document and save it.

13. Now in the git bash terminal execute the command

git add .

This command adds every single file and folder (inside test_repo)to the git and git checks if there is any change in the files as compared to the last commit(In our case it’s the first commit).

14. Now execute the command

git status

This command shows the files which have been changed and needs to be committed.

15. Now execute the command

git commit -m “Your Commit Message”

This command finalizes the changes you have added to git in the git add command. This point will become a permanent checkpoint to which you can come back at any later time.

m flag specifies the commit message which describes the changes made.

16. Now to push the changes(upload the files) to Github, execute

git push -u origin master

Login into your Github account when asked to and the files will be pushed to your Github Account.

17. Refresh Your Github Repository and you should see the changes in the repository on Github.

You just completed your first commit and successfully pushed it to Github using Git.

To gain more insight into Github, try the tutorials on https://guides.github.com/activities/hello-world/.

I hope you had fun learning about Git and Github and I hope you would be able to incorporate Git into your daily workflow for a much better programming experience and to share and collaborate with other people.

--

--

Hemant Jain
Code Dementia

Growing And Trying To Understand The Subtleties Of The World.