Post

GIT cheatsheet

GIT cheatsheet

This is a simple cheat sheet of common git commands that might be useful.

Create local branch

Create and switch to a new local branch

1
git checkout -b <branch_name>

Push local branch to remote

Push your local branch to the remote repository

1
git push origin <branch_name>  

Remove local branch

Delete a local branch safely (only if merged)

1
git branch -d <branch_name>

Remove remote branch

Delete a branch from the remote repository

1
git push -d <remote_name> <branch_name>

Switch to remote branch

Switch to an existing branch

1
git switch <remote_name>

or on older GIT clients create and track a remote branch locally

1
git checkout -b <branch_name> <name of remote>/<branch_name>
This post is licensed under CC BY 4.0 by the author.