I have an unmerged feature branch created more than a year, the feature was never finished. I want to delete that branch and the commits in it.
How can I delete the branch and the commits, the commits aren't useful anymore; I don't want to preserve those commits.
git branch -d <branch_name>
?git branch -d <branch_name>
doesn't remove those commits. It just deletes the branch and gets them out of your way. I would say you probably don't want to remove the commits completely, it will only potentially harm you in the future if you do. Best practice in git is to not change the history, when you don't have to.git branch -D [branch]
the branch and commits are effectively gone from a practical daily usage perspective. Unless you know how to explore local git files to dig up the old commits, it doesn’t exist locally. And the only real risk comes from the branch being pushed remotely. And in a case like that just run this commandgit push origin :[branch]
to delete the remote branch. And if you truly want to nuke local-only commits after agit push
? Delete the local repo copy and do a freshgit pull
of the repo.