我不知道为什么您的问题被否决了,因为这是合法的,而且初学者用户在使用 Git 时常犯的错误。
你不小心BR-02从 branch创建了 branch BR-01。一种解决方案是使用正确的基础创建一个分支,然后挑选您BR-02在该正确分支上所做的任何提交。
git checkout BS-00 # switch to the correct branch
git checkout -b BR-03 # create the correct branch using BS-00 as a base
git cherry-pick <SHA-1> # cherry-pick the commit from BR-02
Run Code Online (Sandbox Code Playgroud)
这<SHA-1>是BR-02您希望保留的分支上提交的哈希值。您可以通过切换到终端BR-02并git log从终端输入来找出该值。
请注意,这有效地将您在 branch 上所做的提交合并BR-02到了 branch 中BR-03,因此可能存在冲突。最后,您可以删除坏分支,BR-02因为您不再需要它:
git branch -d BR-02 # delete the wrong branch BR-02 locally
git push origin :BR-02 # delete the wrong branch BR-02 on the remote
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6706 次 |
| 最近记录: |