我使用 git rebase --onto target source foo
将分支 foo
从分支 source
移动到分支 target
。你知道是否可以像这样使用哈希值而不是分支名称(如果没有给出):git rebase --onto ab91c f4242 foo
?
作为一种解决方法,我临时将分支名称添加到相关的提交对象中。但是,如果您有许多分支需要重新设置基数,这可能会很麻烦。
示例情况:
° bb42a
° ab91c
° 979c2
/° fb648 foo
° f4242 --
° 333c9
在 git rebase --onto ...
之后
° bb42a
/° fb648 foo
° ab91c --
° 979c2
° f4242
° 333c9
背景:
如果您使用 svn-server 作为远程存储库,则解释的问题非常常见。您提交的所有对象都会被重写,因为每次您 git svn dcommit
时都会添加 svn-id 到 svn-repository。这会将所有其他分支从它们以前的 master 中分离出来。
最佳答案
确定的是:
- 一个
git rebase
(不是git-svn rebase
)可以接受任何有效的提交作为参数,因此哈希值将起作用。 - caveat section的
git-svn
确实警告你:
avoid all
git clone
/pull
/merge
/push
operations between git repositories and branches.
The recommended method of exchanging code between git branches and users isgit format-patch
andgit am
, or just 'dcommit’ing to the SVN repository.
因此,您需要确保不要在 SVN 同步分支中引入提交,SVN 同步分支不会知道该提交并会这样报告。
(你在 SQ 问题“ git svn
- <file>
was not found in commit <hash>
”中有相反的情况)
关于git - 如何使用散列而不是分支名称进行 git rebase?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6519400/