Published in


Git: Everything about git.

In this post, we will be exploring about git, and other source control platforms like Github, Bitbucket and Gitlabs.

Let start with what is git?

Git is an essential tool, which every developer needs to understand as it is widely used in the development eco-system and it will be easier, to transition into another team, since it is a practise which is intensely followed.

There are hundreds for command, related to git. But few of commands will be used most, in the latter part of this article, we will be exploring these popular commands.

Since nowadays most of the code editor gives the option of using git through the user interface, which is kind of an easy way of doing things.

But I will suggest, to be clear with the command line of git, then only you will be able to understand user interface easily. If directly someone starts using the user interface provided by code editor, your basics of git will strongly lack.


Git is defined as an open-source version control tool, used to manage small to big open source project. Read more about Git, Git(click here).

Version control can be defined as maintaining a version of the project. This means maybe in future if you want to rollback to the older version or want to check the difference you made to your code, it can be easily done using git.

  1. Understand it like this, git helps you save your life, in case something goes wrong in your code at any time. You can clearly see what changes you made to your code, which could have caused that issue.
  2. Again if you have two developers working the same codebase, then it will be easier for you to merge and deploy your code.
  3. You can maintain branches, which is a different version of the codebase. To elaborate suppose, there are two tasks, the first one is to make a login page API and another one is to list API, which will be returning you some set of data.
    Now you can work on these tasks simultaneously, by making two different branches from the base branch and keep on adding/committing your code.
  4. Similarly, you can share your code and get help from another developer, simply by pushing the code in the branch, sharing the branch name with another developer. If due to any reason you don't want your code to be merged into the main branch you can delete the branch and everything becomes sorted.

Without git, all these task have to perform manually which could be a big and confusing task.

Different types of hosting source control software?

Bitbucket, Github, GitLab etc., there are the few popular tools used to host your code. This tool is used to share code among different developers.
All these source control software provided you with an online user interface where you can check different versions, branches, pull request from your peers.

Most of these have grown up so well, that all your purpose for managing your code becomes very easy. It is hard not to find something in this software which you will be needing.

Few of the git commands:

Frankly saying, there are many commands available when we talk about git, but the following are few of the common one which you will be needing on a day to day basis.

  1. Check branches, for checking how many branches you have on your system. So branches are created to have two different codebases of your project. If you want to work two different tasks simultaneously, this is the best way. As told earlier with these branches you can maintain a different version of your code and also share code with other developers.
    - git branch
  2. Creating a new branch, generally a new branch is creates based on your ticket Id.
    - git checkout -b ‘branch-name’
    Generally, this branch name is the same as your ticketing system id, if you are using Jira for all these purposes, then your Jira id will be used for such purpose. Once you name your branch as per your Jira id, It will link to your ticket, and it will be easier for you to link the code with the ticket.
    - Always name your branch properly, it will save you in long run.
  3. If you want to stash(remove) all your changes, and want to bring your code at your last stable head. This command will remove all the code change, be aware of what changes, have you made. There is another command, which can be used to bring back all the changes which you stash by mistake, that will in point 4.
    - git stash
  4. If you want to recover, what you have stashed before. We have two commands for it
    4.1 git stash pop
    (Bring back last code which you have stashed.)
    4.2 git stash list
    (Check the list of older stashes done.)
  5. Add unstaged file to commit:
    5.1 git add .
    (This command is used to add all the files.‘.’, this dot means to add everything.)
    5.2 get add ‘path to filename’
    (This command is used to add/commit single file name.)
  6. Commit stagged file, so that you create a version of any codebase. So this command will add a git commit id to that particular version of code, which can be used for later reference.
    - git commit -m “message specifying what changes have been made in that commit”
  7. Now once your code is committed you have to now push this code into the source control software you are using, either Github, bitbucket etc.
    - git push origin ‘branch-name’
  8. In case, some other developer make any change and push it to the source control software, you can pull that changes to your local system just by simply
    - git pull origin ‘branch-name’
    Now you have that latest bunch of code, now you can develop it.
  9. To merge two difference code base, merge two different branches to bring codebase together.
    - git merge ‘branch-name’

Till now, we have come across the few commands which are used on a daily basis if you are a software developer.

Git is by far the most used, version control tool which is used by most of the development teams.

If you are starting new on git, you might face some initial hiccups, but once you are through with it, you can’t imagine your life without it.

These are the most common branch name, but still, git has an ocean of command which you can explore once you start working using git.

In case, of any doubt, you can reach out to me, for any clarity. Link to my portfolio is https://apoorv-tomar.web.app/



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store