用于删除尚未推送到远程的不需要的提交的 git 命令是什么?
如果我有一些本地主题分支,我已提交但尚未将它们推送到远程,我该如何删除它们?
我不想用不需要的提交来污染主树。
If I have a few local topic branches I have made commits on and haven't yet pushed them to the remote, how can I delete them?
I don't want to pollute the main tree with unwanted commits.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您还没有将它们推送到远程,那么删除它们应该很容易。
将强制删除您不想保留的分支。
If you haven't yet pushed them to the remote, it should be easy to delete them.
will forcibly delete a branch that you don't want to keep.
尝试查找 rebase - 这里有一系列很好的视频: http://www.ava.co.uk /git
Try looking up rebase- there is a good series of videos here: http://www.ava.co.uk/git
试试这个。这样就可以删除单个提交。我假设您想要删除的提交距离 HEAD 不超过 16 步。
git rebase -i HEAD~16...HEAD
Try this one. This way it's possible to drop single commit. I assume the commit you want to drop is no further than 16 steps back from the HEAD.
git rebase -i HEAD~16...HEAD