I have a GitHub repo with 2 branches, a master branch and a test branch, in both of those branches I have different .htaccess files that I would like to keep in the respective branches and, when merging the test branch with the master branch, not merge the .htaccess files, I would also like to do this for merging any new branches that are created within my repo and the test branch.
Asked
Active
Viewed 189 times
1 Answers
0
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 merging 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.
Many more you can do with .gitattributes here https://git-scm.com/docs/gitattributes

lib4backer
- 3,337
- 3
- 18
- 16