10

I need to exclude the dist/ folder from merging errors, I don't care if it is theirs, ours or other strategy but I need to keep it in the revision control since this is the way to deploy to Heroku. .gitattributes script seems to be the way to go. But I can't seem to make this work.

I read this canonical answer and this similiar answer but can't find out what I'm doing wrong.

My .gitattributes config:

* text=auto
dist/ merge=keepMine

The relevant part of my .git/config :

[merge "keepMine"]
    name = always keep mine dist during merge
    driver = keepMine.sh %O %A %B

and keepMine.sh (in my project root folder, no the folder isn't in the path, but copying to a folder in the path didn't help and isn't a good solution since the script should be part of revision control so all developers would get it):

# copied as is from the SO answer
# I want to keep MY version when there is a conflict
# Nothing to do: %A (the second parameter) already contains my version
# Just indicate the merge has been successfully "resolved" with the exit status
exit 0

EDIT: Also tried git config merge.keepMine.driver true as suggested in one of the SO answers above. Didn't work.

But I'm still getting merge errors (If I create them) for example in dist/styles/sdkasl.main.css for example.

What am I doing wrong? Thanks for the help.

8
  • I'm at best a git novice, but I've been following this question for the past few days hoping to see a solution to your issue. Did you get it resolved? If not, perhaps How to make git ignore a directory while merging can help?
    – user539810
    Jan 24, 2014 at 23:52
  • @ChronoKitsune this is another issue, I don't want to do a manual merge (in which that answer would help) but an automated merge..
    – alonisser
    Jan 25, 2014 at 18:31
  • I just tried what you described and it works for me. Could you please update your question with the output from a failing merge? E.g. GIT_TRACE=2 git merge ...
    – Lasse
    Feb 24, 2014 at 13:10
  • 1
    Please post the output of git check-attr --all dist/styles/sdkasl.main.css
    – jthill
    Apr 30, 2014 at 7:17
  • 1
    Shouldn't this be dist/** in the .gitattributes file?
    – kfunk
    Jan 7, 2016 at 2:01

1 Answer 1

0

The documentation isn't great in this one.

You can also use Git attributes to tell Git to use different merge strategies for specific files in your project.

Sounds great! We can read about merge strategies here and there's one called ours that'd be really helpful.

Unfortunately the next line crushes that dream. Emphasis mine.

One very useful option is to tell Git to not try to merge specific files when they have conflicts, but rather to use your side of the merge over someone else’s.

Sadly for us, if the changes to dist/ in feature don't conflict with master then they'll be merged into dist/ on master. The second answer to the question you linked above discusses this.

I'd suggest a post merge hook that resets dist/ to some pristine state.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.