Git - frequently used git commands on command line

In this tutorial , we will see some of frequently used git commands which can be run on command line.

I am assuming that git is installed , configured with your credentials and cloned the repository into your local machine.  Now lets see the commands which a developer uses for check in and checkout of code on daily basis.

Create a local branch

Above command will create a branch locally. Until you checkout this branch and push it, it will not be available remotely.

Show the list of branches

Checkout an existing branch

Above command will switch or restore the branch to given existing branch.

Create and Checkout branch in single command

It will create a new branch and base branch will be the given existing branch.

Check the status of branch and file changes

It will show the current branch name and both new and modified file list.

git status command result

Stage the changes

Staging of changes means preparing them for commit. Until you stage the changes using this command, same cannot be committed to a branch.

Commit the changes to current branch

This command would commit the current changes which you have seen through status command to the current branch.

Push the changes to remote repository

Pushes the branch with changes to remote repository.



Submit a Comment

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">