简体   繁体   English

什么是git命令来删除尚未推送到远程的不需要的提交?

[英]What is the git commands to delete unwanted commits that haven't been pushed to the remote?

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. 我不想用不需要的提交来污染主树。

If you haven't yet pushed them to the remote, it should be easy to delete them. 如果您尚未将它们推送到遥控器,则应该很容易删除它们。

git branch -D <branch-to-delete>

will forcibly delete a branch that you don't want to keep. 会强行删除您不想保留的分支。

尝试查找变基-这里有很多视频: http : //www.ava.co.uk/git

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. 我假设您要删除的提交距离HEAD不超过16步。

git rebase -i HEAD~16...HEAD

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Git rebase-删除一些已推送到远程存储库的提交 - Git rebase - delete a few commits that have been pushed to a remote repository 如何撤消尚未推送的提交? - How do I undo commits that haven't been pushed yet? Git删除推送提交 - Git delete pushed commits Git:如何确保不将哈希提交/推入尚未推送到远程的子模块? - Git: how do I make sure I don't commit/push hashes to submodules which haven't been pushed to remote yet? GIT:如何压缩已被推送到远程仓库的几个提交? - GIT: how to squash several commits that have been pushed to a remote repo? 如何查看尚未推送的提交列表? - How do I view the list of commits that haven't been pushed yet? 如何修复我的本地存储库,以便我可以保存尚未推送到主 git 存储库的提交的工作? - How do I fix my local repo so I can save work from commits that haven’t been pushed to the master git repo? 删除远程git上的提交 - Delete commits on remote git 撤消已推送到远程仓库的提交 - Undoing commits that have been pushed to remote repo 在git中,如果我在远程存储库中推送了3次提交,将会对文件应用什么? 将应用最新的推送提交还是第一次应用? - In git What will be applied into the file if I pushed 3 commits in the remote repository? Will the latest pushed commit will be applied or the first?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM