Display help information about Git

git help

A tutorial introduction to Git.

git help tutorial

A useful minimum set of commands for Everyday Git.

git help everyday

An overview of recommended workflows with Git.

git help workflows


Get and set repository or global options

git config

Set name attached to commit transactions.

git config --global user.name [name]

Set email attached to commit transactions.

git config --global user.email [email]


Create an empty Git repository or reinitialize an existing one.

git init [project]

Clone a repository into a new directory.

git clone [url]

Inspect working tree

Show the working tree status.

git status

Show status. Give the output in the short-format.

git status -s

Show changes in working tree.

git diff

Inspect staged

Show changes between staging and the last file version.

git diff --staged

Inspect history

Show commit logs.

git log

Check log from a branch.

git log origin/branch -2

Show various types of objects. e.g. commit

git show [commit]

View more details about tag.

git show [tag]


List, create, or delete branches.

List branch

List local branches.

git branch

List both remote-tracking branches and local branches.

git branch -a

Create branch

Create new branch.

git branch [name]

Rename branch

Rename branch.

git branch -m oldName newName

Delete a branch

Soft delete

git branch -d [name]

Hard delete

git branch -D [name]

Checkout branch

Switch branches or restore working tree files.

git checkout

Switch to branche.

git checkout [branch]

Creates a new branch and immediately switches to it.

git checkout -b [branch]

When creating a new branch, if no -b option is given, the name of the new branch will be derived from the remote-tracking branch.

git checkout -t [origin/branch]

Merge branches

Join two or more development histories together.

git merge

Merge a branch to (current) branch.

git merge [branch]

Add tracking

Track change of a file contents by adding to the index

git add [file]

Rename file or directory

Move or rename a file, a directory, or a symlink.

git mv [from] [to]

Remove tracking

Remove files from the working tree and from the index.

git rm [file]

Removes the file from version control but preserves the file locally.

git rm --cached [file]


Stash the changes in a dirty working directory away.

git stash

Lists all stashed changesets.

git stash list

Restores the most recently stashed files.

git stash pop

Discards the most recently stashed changeset.

git stash drop

Commit change

Record changes to the repository

git commit -m "[descriptive message]"

Correct last commit.

git commit –amend -m "[descriptive message]"

Undo change

Revert contents of a file, or obtain a deleted file from local repository.

git checkout [file]

Reset command is used to reset or revert changes.

git reset

Undo stage change

Unstages the file, but preserves its contents.

git reset [file]

Undo commit change

Undoes all commits after [commit], preserving changes locally.

git reset [commit]

Undoes last commit.

git reset --soft HEAD^

Discards all history and changes back to the specified commit.

git reset --hard [commit]

Redo change

Reapply commits on top of another base tip.

git rebase


List, create, delete or verify a tag object signed with GPG.

git tag

View all available tags.

git tag -l

Create tag, tag current HEAD

git tag -a 'Release_1_0' -m '...' HEAD

Delete tags from local as well as the remote repository.

git tag -d Release_1_0


Prepare patches for e-mail submission.

git format-patch -1

Apply a patch to files and/or to the index.

git apply [patch]

Apply a series of patches from a mailbox.

git am [patch]


Manage set of tracked repositories.

git remote

Print all remotes' fetch/push URLs.

git remote -v

Add remote as origin.

git remote add origin git@...

Print remote origin.

git remote show origin


Download objects and refs from another repository.

git fetch


Fetch from and integrate (merge) with another repository or a local branch.

git pull


Update remote refs along with associated objects.

git push

Push update to origin's master branch.

git push -u origin master

Update a branch.

git push origin branch

Push send update to a remote repository.

git push origin master

Push tag into the remote repository.

git push origin tag Release_1_0