バージョン番号が 2 つのブランチで増加するファイルがある場合、Git がバージョンを定義する行を変更する 2 つの行をサイレントに自動マージするのを防ぐにはどうすればよいですか?
* Git automatically merges here, but shouldn't
|\
| * change same line to the same new text
* | change some line here
\|
* prior history/root commit
私たちの場合、移行をサポートするデータベース スキーマがあります。メイン スキーマ ファイルは、現在のスキーマ バージョンを定義します。2 人がスキーマを変更した場合 (データベース列を追加するなど)、異なるテーブルで両方ともスキーマのバージョンを+1増やした場合、 Git は何も言わずにすべてをマージしますが、結果は壊れます。
Git がこの特定の行を自動マージしないようにする任意の行に追加する特別なマーカーを用意することをお勧めします。私が知らないこのような機能はありますか、またはどのように達成できますか?
問題を説明する Git 履歴の例を作成するためのシェル コマンドのリストを次に示します。
$ git init test
Initialized empty Git repository in $PWD/test/.git/
$ cd test/
$ echo "version 1" > file
$ git add file
$ git commit -m "add file v1"
[master (root-commit) 4ef6950] add file v1
1 file changed, 1 insertion(+)
create mode 100644 file
$ git checkout -b a
Switched to a new branch 'a'
$ echo "version 2" > file
$ git commit -a -m "bump to v2"
[a 85dba39] bump to v2
1 file changed, 1 insertion(+), 1 deletion(-)
$ git checkout -b b master
Switched to a new branch 'b'
$ echo "version 2" > file
$ git commit -a -m "bump to v2 in b"
[b b0fcf46] bump to v2 in b
1 file changed, 1 insertion(+), 1 deletion(-)
$ git merge a
Merge made by the 'recursive' strategy.
$ git status # shouldn't be clean
On branch b
nothing to commit, working directory clean