Branches pile up. Teams name them by purpose, feature/… for new work and fix/… for bug fixes, and delete them once they're done.
-d deletes a branch whose commits are already in the branch you're on, so nothing is lost:
git branch -d feature/done
Deleted branch feature/done (was 8cf7637).It refuses a branch with commits that aren't on the branch you're on: unmerged work.
git branch -d spike
error: the branch 'spike' is not fully merged
hint: If you are sure you want to delete it, run 'git branch -D spike'
hint: Disable this message with "git config set advice.forceDeleteBranch false"-D deletes it anyway, and those commits with it. Be sure first.
git branch -D spike
Deleted branch spike (was 00403e6). ← the hash, in case you need it back-m renames a branch:
git branch -m faqpage feature/faq-page
git branch
feature/faq-page
* mainObjectives
- Delete the branch that's already in
main. - Throw away the font experiment.
- Rename
searchbartofeature/search-bar. - Keep
feature/checkout.