Git remove root commit

后端 未结 2 1908
心在旅途
心在旅途 2020-12-11 15:49

I can\'t do a lot of things with git and I want to remove a commit from my repo, because I uploaded wrong stuff.

I used git revert bu

2条回答
  •  無奈伤痛
    2020-12-11 16:33

    For removing a root commit, you simply have to remove all branches (and tags) from which it is reachable.

    This can be done with git branch -D branch-name. (You will have to first check out another branch which does not refer to this root commit, since you can't remove the current branch, I think.)

    If you want to retain other commits on this branch and only remove the root, git filter-branch is better, see the answer from Greg.

提交回复
热议问题