0

I'd like to remove a branch which contains only one commit. This branch has not never merged.

This is the log:

* 3554555 - (6 days ago) SHA-1 to SHA-2
* 6526045 - (6 days ago) swagger updated
| * f9026f1 - (5 days ago) Using LocalDateTime (HEAD -> dates)
|/  
* bf2c6c2 - (6 days ago) Collect request parameters on audit

So, I'd like to remove this orphan dates branch and its commit f9026f1.

Any ideas?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Jordi
  • 20,868
  • 39
  • 149
  • 333
  • What is wrong with just deleting the branch? The single commit `f9026f1` should eventually be garbage collected by Git anyway, or you could force a garbage collection. – Tim Biegeleisen Nov 14 '18 at 10:44
  • Possible duplicate of [How do I delete a Git branch both locally and remotely?](https://stackoverflow.com/questions/2003505/how-do-i-delete-a-git-branch-both-locally-and-remotely) – phd Nov 14 '18 at 13:42
  • https://stackoverflow.com/search?q=%5Bgit%5D+delete+branch – phd Nov 14 '18 at 13:42

1 Answers1

3

You certainly can reset the head of the branch

git checkout dates
git reset --hard HEAD~1

But frankly, since the branch is just a human friendly name given to a commit id, why not just delete it and fork a new one.

git checkout master
git branch -D dates
hspandher
  • 15,934
  • 2
  • 32
  • 45