Git Commands

A Reference Guide

Git Branch Commands


  • git branch - Display a list of the local branches in your Git repository.
  • git branch -a - Display a list of both local branches and remote branches in your Git repository.
  • git branch -c - Copy a Git branch.
  • git branch -d <branch-name> - Delete a local Git branch. This command will not work if the branch you are attempting to delete has unmerged changes.
  • git branch -D <branch-name> - Delete a local Git branch with unmerged changes.
  • git branch -m <branch-name> <new-branch-name> - Rename a Git branch.
  • git branch -r - Display a list of the remote branches in your Git repository.
  • git push <remote> --delete <remote-branch-name> - Delete a remote Git branch.
  • git push --set-upstream <remote> <branch> - Set an upstream branch. Running this command will push your local branch to the new remote branch.

Git Cherry Pick Commands



Git Commit Commands


  • git status - Display a list of files in your staging directory with accompanying file status.
  • git add - Stage file changes. Running this command with an associated file name will stage the file changes to your staging directory.
  • git commit - Save changes to your Git repository. Running this command with an associated file name will save the file changes to your repo.
  • git commit -a - Add all modified and deleted files in your working directory to the current commit.
  • git commit --amend - Amend a Git commit. Edit a Git commit message by adding a message in quotation marks after the command.
  • git commit -m - Add a Git commit message. Add your message in quotation marks following the command.

Get updates when we publish new concepts by signing up for our newsletter!