Skip to content

Instantly share code, notes, and snippets.

@malkab
Last active September 29, 2022 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malkab/1ff23b8d02d0de4ab0762e09b91f37ae to your computer and use it in GitHub Desktop.
Save malkab/1ff23b8d02d0de4ab0762e09b91f37ae to your computer and use it in GitHub Desktop.
Git - Branches
# Fetch remote branches info
git fetch -av
# Check a branch from a remote and track it
git checkout -t origin/remote-branch-name
# To change the name of the local branch on checkout (not recommended)
git checkout -b local-branch-name origin/remote-branch-name
# Delete remote branches (and their local counterpart)
git push origin :branchtodelete
git fetch --prune
# Delete local branches
git branch [ -D / -d ] branchname
# To check all branches, local and remote tracked
# Branches are not pulled, however
git branch -av
# To check diff between branches
git diff [ branch name ]
git difftoom [ branch name ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment