EVERYTHING YOU NEED TO KNOW ABOUT GIT | GIT 101

EVERYTHING YOU NEED TO KNOW ABOUT GIT | GIT 101

How to use Git version control. Everything you need to know before using git.

4 MINUTE READ

If you have never worked with github before, then it can be a bit confusing to start with, all those terminal commands. Push Pull Merge etc. But honestly, its quiet simpe once you understand what everything is.

Okay so lets answer the question

WHAT IS GIT?.

In simple words , Git is a type of version control system or (VCS). Its sole purpose is to track changes to your project. It is very helpful when more than 1 person is working on the source code.


DIFFERENCE BETWEEN GIT AND GITHUB.

The key difference is that unlike Git which a programmer installs locally , Github is an online platform where you can share project with rest of the world, work with people together on a single project or contribute in someone’s project.

Basically a social media platform for coders 🙂


1. START WITH YOUR FIRST PROJECT ON GITHUB.

Note: A repository is basically a structure where you will upload your project source code.Source Github- Provide a name for your repository After this you will see a page like thisSource Github

With this we are done with step one!!

Copy the link you see https://github.com/username/repo.git on your repo page.


2. INSTALL GIT LOCALLY

Now its time to spin up your terminal and start with git locally, if using windows then powershell can be used.

  • First check whether you have git installed or not use git --version -> git version 2.25.1
  • If you get the above output then you can move to next step otherwise use sudo apt-get install git for debian and ubuntu users or look on official guide to find git for your linux distro/windows.
  • Once you are done with git installation, create a new folder, start an empty git repo using git init. You will see something like this on your terminal

Source My Linux


3. PUSH FILE TO GITHUB

Till now we have our Github repository and a local repository created by git on last step. Now its time to first connect both of them and then push a file to it.

CONNECT LOCAL GIT REPO TO GITHUB REPO

Remember I told you to copy the link of your github repo, its time to use it. – To connect the local repo to github use command git remote add origin <url>.

After this you can check it by using git remote -v Your terminal will look something like thisSource My Linux

Lets understand this command!! So here we created an alias origin for our github repo, the benefit of this is if you are working with multiple online version control platform. You can connect to all of them using single project just by creating differnt remotes.

Eg: git remote add heroku <url> This will create two remotes, one origin another heroku.

Once we are done with creating remotes, next step is to push something to github.

CREATE FILE

  • Create a file touch README.md
  • Put something inside it echo "#First Commit" > README.md
  • Cat README.md

Source My Linux

PUSH TO GITHUB

After we are done creating file, lets push it to Github. – git add . – git commit -m "Message for commit eg: First commit" – git push origin master

It will ask for your github credentials, with this your terminal will look something like this.Source My Linux

Done!! Check your Github Repository , you will see the file there, uploaded with your commit message.Source My Linux

Congrats!! You have successfully pushed your first file to github.

In next article we will dive a bit deeper into git , will talk about Merge requests, Branches, Rebasing etc. So stay Tuned.


REVIEWS

If You find it interesting!! we would really like to hear from you.

Ping us at Instagram/@the.blur.code

IF YOU WANT ARTICLES ON ANY TOPICS DM US ON INSTA.

Thanks for reading!! Happy Coding

Leave a Reply

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

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top
Hey, wait!

Before you dive into the exciting Article, wanna join our newsletter list, We promise we will not spam