git merge 忽略一个文件
实验环境:
git version 1.8.3.1,centos7.6
背景:很多时候,由于特定的分支对应特定的环境,有特定的配置文件,希望合并分支的时候,保留各自的配置文件。
网上很多使用 .gitattributes 的方案,但是这个需要被忽略的文件merge 时产生冲突,否则无效
本实验方案如下:合并时忽略 myfile.txt
git merge --no-ff --no-commit <merge-branch>
git reset HEAD myfile.txt
git checkout -- myfile.txt
git commit -m "merged <merge-branch>"