0
git
保留之前的回购承诺。我想知道如何从我的回购历史记录中进一步删除特定的提交(我有它的ID)?如何从仓库中删除以前的git提交?
git
保留之前的回购承诺。我想知道如何从我的回购历史记录中进一步删除特定的提交(我有它的ID)?如何从仓库中删除以前的git提交?
正如所解释的https://stackoverflow.com/a/42522493/1507546,您可以使用git rebase
# 06c8c77^ means the commit just before 06c8c77
git rebase -i 06c8c77^
# Your default editor configured for git will be opened with line similar to the following
在第一部分中,你会看到许多提交,你要删除的一个是在底部,你可以比较的是,提交哈希值。
pick 91c0bd0 track one
....
pick 06c8c77 bla bla bla # the one to remove
将其删除,并在第二部分的解释,所有你需要做的是,从编辑器删除行。
# ....
#
# If you remove a line here THAT COMMIT WILL BE LOST.
之后,您应该保存并退出编辑器。如果这没有错误,您需要更新远程分支。如果你的分支的名字是feature/my_branch
例如,你需要做到以下几点:
git push -f origin feature/my_branch # -f or --force to replace the remote feature/my_branch with the local one
注:只要使用rebase
时,只有单个开发人员才能使用该分支,这是安全的。
可能的重复[删除提交从中间的分支](http://stackoverflow.com/questions/42518104/removing-commit-from-middle-of-a-branch) –
任何人都可以请解释我吗? ?我没有明白 –