基本上,当我想在同一个文件中提交由git add --patch <file>
操作导致的两个单独的更改时, git svn rebase 稍后会在用于第二次更改时在提交第二次更改时引发 1-2 冲突git add
。
所以我基本上是这样做的(我在 master 分支上并且已经获取了 svn 存储库):
git checkout -b feature
... make two unrelated changes to file test.txt...
git add --patch test.txt
... add first change but ignore second one
git commit -m "change1"
git stash
git checkout master
git merge feature
git svn rebase
git svn dcommit
git checkout feature
git stash apply
现在这里有两种方法可以做到,第一种可行:
git add --patch test.txt
... select everything (which is the second change in this case)
git commit -m "change 2"
git checkout master
git merge feature
git svn rebase
git svn dcommit
这是一个不起作用的:
git add test.txt #notice there's no --patch
git commit -m "change 2"
git checkout master
git merge feature
git svn rebase #yields a conflict
那么为什么在git add --patch
用于第二次更改时,我可以毫无问题地提交到svn存储库,但是当仅git add
用于第二次更改时,会导致冲突?我对 git 很陌生,所以这可能是一个愚蠢的问题,但在我看来,两个命令集应该完全相同。