Bitbucket Server - ignore certain files during auto-merge

1.4k views Asked by At

I want to ignore my project version file from auto-merge in Bitbucket Server as this file is always going to be different for different branches. For this, I have created a merge driver similar to the below in repository's .gitconfig

[merge "ours"]    
    driver = true

I have added .gitattribute file at the root of the repository with the below content (to ignore this file for the merge):

version.txt merge=ours

However, Bitbucket Server, doesn't seem to use the .gitconfig settings in my repo and it always conflicts on this file. How can I configure bitbucket server to read and apply the my settings in .gitconfig?

2

There are 2 answers

0
code1x1.de On

I think you should refactor your build completely. Why aren't you just versioning your master branch. Are your sub branches really versioned? You could create a git hook for tagging branches where you simple write a bash command writing the version to your version.txt file

0
Konstantin Yovkov On

I had the same problem recently and the only workaround that Atlassian currently suggest is the following:

  • Login to your Bitbucket server via terminal.
  • Execute git config --global merge.ours.driver true

This will activate your custom merge strategy and the next time you create a pull request that has a conflict on the version.txt file, it will be automatically resolved, by applying the "ours" (destination branch) state.