I have the following git repo structure:
a-b-c-d-.. [master]
\
x
The commit x was accidentially done (can't figure out how) and has no named branch. How can I delete this commit?
For detail, git log shows this (Translated back from german, sorry for any inconvieniances):
Author: ...
Parents: 8444..
Branch:
Follows up:
Preceding:
...
The commit was not 开发者_如何学运维removable via git prune
.
If x isn't in any branch's history, and isn't checked out, it will automatically be removed by git sooner or later. You can look at git help gc
if you want to remove it right away. Setting gc.reflogExpireUnreachable
to zero and then doing git gc --prune=now
will probably do the trick.
git rebase
, git commit --amend
, and other such commands leave these kind of leftovers all the time; git is usually decent enough at dealing with them that you don't have to worry about it.
git prune
will do what you want, but it will delete all unreachable objects, not just a specific one.
Run git gc
aggressively. May take time.
git gc --aggressive
More on git gc
here.
精彩评论