我有一个分支已被提交,推送并合并到主。它没有通过QA。我们需要将该分支从主发布版本中释放出来。我如何将这个分支拉出主人。假设分支名是“被移除”Git:我如何删除已经被提交,推送并合并到master中的分支?
1
A
回答
0
如果,另一方面,要真正摆脱自那以后,你所做的一切,有两种可能性。一,如果你还没有发表任何这些提交的,简单复位:
# This will destroy any local modifications.
# Don't do it if you have uncommitted work you want to keep.
git reset --hard 0d1d7fc32
# Alternatively, if there's work to keep:
git stash
git reset --hard 0d1d7fc32
git stash pop
# This saves the modifications, then reapplies that patch after resetting.
# You could get merge conflicts, if you've modified things which were
# changed since the commit you reset to
在另一方面,如果你已经发表的工作,你可能不希望重置分支,因为这是有效的重写历史。在那种情况下,你确实可以恢复提交。使用git,回复具有非常明确的含义:使用反向修补程序创建提交以将其取消。这样你就不会重写任何历史。
# This will create three separate revert commits:
git revert 0766c053 25eee4ca a867b4af
# It also takes ranges. This will revert the last two commits:
git revert HEAD~2..HEAD
# To get just one, you could use `rebase -i` to squash them afterwards
# Or, you could do it manually (be sure to do this at top level of the repo)
# get your index and work tree into the desired state, without changing HEAD:
git checkout 0d1d7fc32 .
# and then commit
git commit # be sure and write a good message describing what you just did
2
你应该有这样的历史:
A--B--C---D--E <-- Master
\ /
Z--Y--X <-- Your feature
你想从主分支中删除承诺d。你只需要恢复这个提交。有一个git命令是:
git revert -m 1 [sha_of_D]
其中-m
意味着提交父数。
它将在master中创建一个新的提交,撤消您的功能分支所做的更改。欲了解更多信息,你可以去the main source。
相关问题
- 1. Git合并我已经推送到远程原点的提交
- 2. 我已经推入Git后如何合并提交?
- 3. Git合并分支提交
- 4. 如何从git中的已推送分支中删除所有提交?
- 5. 合并并推送所有git分支
- 6. 删除git中的合并分支提交
- 7. Git将branchX合并到master中。删除branchX并启动新的新分支X?
- 8. 阻止git合并到master分支
- 9. 混淆git合并,如何合并master到分支但保持分支分开
- 10. Git合并中间提交的分支
- 11. Git删除推送提交
- 12. 如何删除提交已被推到使用Git
- 13. 如何从git中的多分支合并中删除分支?
- 14. 如何列出合并到master的git分支并删除分支(如果它看起来不错)?
- 15. 移动一些已经存在并推送提交到一个新的分支
- 16. 合并Git分支和删除也会删除master中的文件吗?
- 17. 如何在Git中提取并移除合并的分支?
- 18. git rebase interactive已经推送提交
- 19. 为什么本地分支上的“git push”导致与“develop”合并并推送到“master”分支?
- 20. Git-svn合并和提交分支
- 21. 合并git分支时,如何避免提交日志分支?
- 22. git提交并推送本地git文件夹,无需合并
- 23. git:合并两个分支并提交提交
- 24. 删除上次提交并推送
- 25. Git Rebasing Branch Commits,当它已经分开合并分支提交它?
- 26. 我该如何合并一个已经解决了与master冲突的分支?
- 27. 从git master删除合并文件
- 28. 如何合并dev分支中的文件到master分支
- 29. 从Git中删除推送提交
- 30. 删除已经承诺的git分支