git ignore some files during a merge

Let's say you want to exclude the file config.php

On branch A:

Create a file named '.gitattributes' in the same dir, with this line: config.php merge=ours. This tells git what strategy to use when mergin the file. In this case it always keep your version, ie. the version on the branch you are merging into.

Add the .gitattributes file and commit

On branch B: repeat steps 1-2

Try merging now. Your file should be left untouched.

Related posts:

This entry was posted in git, knowledge. Bookmark the permalink.