Deleting
Merged local branch
git branch -d old-name
Safely deletes a merged branch. Git refuses when the branch has unmerged commits; see the git-branch manual.
Unmerged local branch
git branch -D old-name
Deletes unmerged work. Forces deletion even with unmerged commits, so check them first; see the git-branch manual.
Remote branch
git push origin --delete old-name
Removes the branch on the remote. Local branches and other clones are untouched. See the git-push manual.
Stale tracking refs
git fetch --prune
Prunes stale remote-tracking refs. Removes local origin/* refs whose remote branch is gone; see the git-fetch manual.
Related links
- git-branch manual (git-scm.com)
- git-push manual (git-scm.com)
0 Comments for this cheatsheet. Write yours!