Ad

GIT Cheat Sheet – A list of commonly used GIT commands [Bookmark]

Posted git

The author voluntarily contributed this tutorial as a part of Pepipost Write to Contribute program.

Introduction

Today most of the developers manage their projects using Git, a distributed version control system that supports collaboration. The objective of this Git Cheat Sheet Guide is to provide you a quick reference to commands which you can bookmark and use while working and collaborating in any Git repository.

GIT BASICS

Command

Description

git init

Create empty repo. Details

git clone <repo>

Clone existing repo. Details

git add <filename>
git add *

Stage all changes. Details

git commit -m "<message>"

Commit changes with a message. Details

git status

List staged/unchanged/untracked. Details

git log

Display commit history. Details

git diff

Show unstaged changes. Details

GIT BRANCHES

Command

Description

git branch

List branches. Details

git branch <branch>

Create a new branch. Details

git branch -D <branch>

Delete a branch. Details

git checkout <branch>

Checkout existing branch.Details

git merge <branch>

Merge a branch into the current branch. Details

LOCAL & REMOTE MODIFICATIONS

Command

Description

git stash

Save modified + staged changes.Details

git reset <file>

Remove the file from staging.Details

git revert <commit>

Create a new commit, reverting a previous commit's changes.Details

git rebase <branch>

Combine the last commit + staged changes.Details

git reset --hard <commit>

Clear stagging area, rewrite working tree. Details

SHARE & UPDATE

Command

Description

git remote add <alias> <url>

Add git URL as an alias.Details

git fetch <alias>

Fetch all remote branches.Details

git merge <alias>/<branch>

Merge remote into the current branch.Details

git push <alias> <branch>

Push local commits to a remote repo.Details

git pull

Fetch + merge remote commits.Details

git rm

Remove files from the working tree and from the index.Details

git remote set-url

Changes URLs for the remote. Sets first URL for remote that matches regex (first URL if no is given) to . If doesn’t match any URL, an error occurs and nothing is changed. Details

We request you to bookmark this Page as more Such Commands and Descriptions are coming your Way.

Thank you for Reading and Happy Coding!