Minimum GIT knowledge that every IT guy must know.!
By: Sudeep Nellur
Tags: Github, Distributed Systems, Git Basics, Version Control, Git

So what is GIT?🤔

GIT is open source distributed version control system designed for coding projects among your teams. In simple words, a project will be assigned between you and your teammates where you and your teammates will share your part of source code to some sort of distributed system and later those complete source codes will be shipped to real world. Simple.!

How GIT works?🤓

Let’s assume you got a project to do and you will write some 4–5 scripts to do all the tasks and save it in one directory or folder, this is called as GIT Repository. Git Repository will simply have all the scripts and configuration files needed for the project under one folder, likewise multiple projects will have multiple repos in git( “repos” is short word for git repositories and it sounds cool😂).

sorry for my bad drawing :(

Also you can have folders inside folder. example if you are done with project and later you want to add some extra features but you are not sure whether the new changes will be break or make project. In this situation we will make a copy of existing code in one folder say folder name as “main” and copied folder name as “extras” and if code inside “extras” folder works you will simply replace “main” with “extra” folder for working. So this functionality in git we call it as Branching. Branching is a processing where the existing code is further copied for new development leaving existing code as backup in case of failure. And the “main” folder here is called as Master or Main branch and “extras” folder can be called as however you want like dev1, dev2 and so on. And replacing the folders will be called as Merging the branches.

To revision, Repository is the folder for the project, Branches are the folders for each build where the main working code folder is called as Master or Main and remaining are just branches with name you will give to it, and replacing the new working folder with current working folder is called as Merging the branches.

To work with git there will be three stages in total to get your code from your local directory to git repo, namely Local Directory, Staging and Repository. Local Directory(your pc) is the folder where you have edited the code and further you can push that code to Staging(decide before pushing) which means the code will be staged but it will be not pushed yet to any repo, In this phase you will decide to which branch you need to push the code on and that pushing of code to git is called as Repository(pushed).

The pushing of code from local directory to staging phase is called as Git Add and pushing code from staging to repository phase is called as Git Commit.

Now enough of theoretical knowledge and this much of concepts is necessary or enough for any IT guy to get started, yeah there are still more to learn and we just stretched the surface but for any beginner this much is sufficient. And it’s time to get our hands dirty with some hands-on now. There are some many services for GIT now-a-days namely Github, GitLab, Bitbucket and newly added AWS’s CodeCommit and Google’s Cloud Source and so on and also all tools works pretty much same. Here we go with Github and I also recommend to go with GitHub first. There are many reasons to go with GitHub, here I will mention some.

GitHub have got biggest community compared any other git services out there with 40 million users all around the world.

As GitHub community is big, The most Open-Source projects happen over here which is kinda cool.

GitHub also got GitHub Pages which makes GitHub stand-out from the rest where using this you can basically host website for FREE.

which makes GitHub stand-out from the rest where using this you can basically host website for FREE. And also most the services like Heroku and etc, are compatible with it.

Now before you moving up with it, you need to make a GitHub Account for it so get done with that first and also install it.

After creating account will be directed to dashboard where you need to go to “Your Repositories” where you will press “new” button for creating new repository .

Next up, you need to name the repository however you want and press “Create Repository” and this will create your repo.

After this you need to open command prompt and direct to your code directory or you can also go for GUI also but I suggest you to be a Pro and use Cmd or Terminal. After going into Cmd or Terminal just type:

git init

This will be basically create a git file for you where you need to store github remote address and to add new remote address you simply just re-type the command. Now you need to add the remote address to it for this first copy the link from repo by clicking on “code” and further clicking on copy or writing pad icon, This will copy your git address.

Then add it to your git file just by pasting or just by right clicking infront of this below command. This will add connection between yours local directory to github repo.

git remote add <link>

Further you need to add your files to staging phase by giving command add, refer above image for clarification. You add files by giving out the name of the specific file or if you wanna add all of them then just type dot.

git add <filename> or < . >

Now that your files are staged, all you need to do is pushing it to desired branch and that can be done by below command.

git push origin <branchname>

And that’s it you have just created and pushed your code to github and even you check that in website too. Do this for 4–5 repos and then you can confidently add GitHub skill in CV. Thank you for reading and Keep Learning..!😀