During last few months I found many freshers struggling with GIT, many claim “it is very easy to code but far difficult to commit”, that sounds crazy. In my last company (that claims to be amongest largest Mobile application development company) I found developers keeping zip back up of their code EOD, that was irritating to see
So, I just decided to write on this topic, Git: It is developers’ friend not enemy, so without spending much time on why did I write this blog, let us start 🙂
What is GIT?
Git is a distributed version control system that keeps the collection of files at particular instance as a snapshot
Git Repository is history of all the snapshots (versions), currently pointing latest stable commit as head
Branch: When one says git supports branching that means that one can work on different versions of collection of files. A branch separates these different versions and allows the user to switch between these version to work on them.
For example if you want to develop a new feature, you can create a branch and make the changes in this branch without affecting the state of your files in another branch.
Git allows us to merge these features as well, explained next about Merge
Merge: As already defined merge is process of combining code from different version of files with different features to build final product.
Suppose you’ve decided that your issue #xx work is complete and ready to be merged into your master branch. In order to do that, you’ll merge in your current branch, All you have to do is check out the branch you wish to merge into and then run the git merge command:
$ git checkout master
$ git merge <current branch name>
Working Tree: Working tree is current set of files that a developer is working with
Staging Area: To understand what staging area is we need to first understand stages of File status in Git
Untracked: These are files that are present on local system of developer but still not added to remote
Tracked : list of files already present on remote
Dirty/Modified: These are files that have some changes
Staged: These are files that are selected for user to commit to remote and combination all these files comprise staging area
Head : Head is symbolic reference to current branch
Tag: Tagging is simply marking some points in history as being important. Generally, people use this functionality to mark release points (v1.0, and so on).
Now we are through basic terminology, Lets start with Actual git commands and process
Creating a Repo
First you need to create a repo on git hub or Bitbucket
If you choose github.com create a repo, you will see a repo created with few files like readme.md etc
just copy clone URL from repo like
open terminal type git clone “url”
you will see repo cloned on your machine
If you choose latter, you will have a git empty repo created
you need to follow following steps:
1) git init
2) git remote add origin <url>
3) git push -u origin –all # pushes up the repo and its refs for the first time
4) git push -u origin –tags # pushes up any tags
5) Open git cola/git gui and stage file that you need to commit in case you have no git cola installed on your machine, obviously you need to install the same.
6) Commit the code using gitcola/git gui
7) git push -u origin master
You are done with first commit!!!