LoginSignup
17
14

More than 5 years have passed since last update.

追記専用のファイルでコンフリクトを抑止する

Posted at

ChangeLog とか Android アプリの string.xml の様に、特定の箇所に行が追加されていくだけのケースで、複数の人が作業すると頻繁にコンフリクトが発生してしまいます。

大抵のバージョン管理システムではファイル毎にマージに使うコマンドを指定できるようになっていますが、 git の場合は .gitattributes ファイルで指定します。

$ echo "string.xml  merge=union" >> .gitattributes
$ git add .gitattributes
$ git commit -m "string.xml: merge=union"

merge=union の部分がマージドライバーの指定で、 union は順番を気にせずに両方の内容を保存するマージドライバーです。
このドライバーを使うと同じ行を別々の人が追加した時に重複してしまう可能性もあるので、ファイルが壊れたら手動で直せる場合にだけ、注意しながら使ってください。

他にも自分でマージドライバを作ることもできるます。詳しくは git help attributes を参照してください。

17
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
14