Some useful GIT commands:

git-logoGit is a distributed version control and source code management (SCM) system. It is designed and developed by Linus Torvalds for Linux kernel development, Git has since been adopted by many other projects.

In this tutorial I will show you some basic git commands to work with Git.

Create a new local repository

Add one or more files to staging (index):

Commit changes to head (but not yet to the remote repository):

Commit any files you’ve added with git add, and also commit any files you’ve changed since then:

Send changes to the master branch of your remote repository:

Status List the files you’ve changed and those you still need to add or commit:

If you haven’t connected your local repository to a remote server, add the server to be able to push to it:

List all currently configured remote repositories:

Create a new branch and switch to it:

Switch from one branch to another:

List all the branches in your repo, and also tell you what branch you’re currently in:

Delete the feature branch:

Push the branch to your remote repository, so others can use it:

Push all branches to your remote repository:

Delete a branch on your remote repository:

Fetch and merge changes on the remote server to your working directory:

To merge a different branch into your active branch:

Remove merge conflicts:

Preview changes, before merging:

After you have manually resolved any conflicts, you mark the changed file:

You can use tagging to mark a significant changeset, such as a release:

Commit Id is the leading characters of the changeset ID, up to 10, but must be unique. Get the ID using:

Push all tags to remote repository:

The following two tabs change content below.

Tapas Mishra

Sr. Engineer (DevOps)
Loves to work on Opensource products. Having experience on Linux environment. Knowledge on Public cloud services like AWS, Rackspace, DigitalOcean, Linode. Please don't hesitate to give a comment on the posts. Your comments are my strength.

Leave a Reply