基本的に、操作の結果として同じファイルに 2 つの個別の変更をコミットしたい場合、git add --patch <file>
後で git svn rebase を使用git add
すると、2 番目の変更をコミットするときに 1-2 の競合がスローされます。
だから私は基本的にこれをやっています(私はマスターブランチにいて、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
ここには2つの方法があります。最初に機能する方法は次のとおりです。
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
では、2回目の変更に使用git add --patch
すると問題なくsvnリポジトリにコミットできるのに、git add
2回目の変更にのみ使用すると競合が発生するのはなぜですか? 私は git にまったく慣れていないので、これはばかげた質問かもしれませんが、私が見る限り、両方のコマンドセットはまったく同じように動作するはずです。