Johan Hjalmarsson
Johan Hjalmarsson

Reputation: 3493

gitattributes -merge for one specific directory (existing repo)

Sorry if this is a duplicate. I've searched but not found anything that seems to work.

I have a git repo that is up and running with history, different branches etc.

The repo doesn't have a pre-existing .gitattribute file, so I've added one.

My .gitattribute is located in the root folder and contains the following:

#I've tried the following:
#./src/views/component-testing -merge
#./src/views/component-testing/*.* -merge

#Current content:
./src/views/component-testing/* -merge

I'm then trying to merge another branch (with a conflicting file in component-testing) into my current one. This is the result:

> git merge conflicting-branch
Auto-merging src/views/component-testing/component-testing.tsx
CONFLICT (content): Merge conflict in src/views/component-testing/component-testing.tsx

Why isn't this working?

Upvotes: 0

Views: 304

Answers (1)

Edward Thomson
Edward Thomson

Reputation: 78893

There's three problems here:

  1. -merge looks like an attribute for the .gitattributes file, it does not belong in the .gitignore.

  2. -merge doesn't mean "don't merge these files", it means that these files are not automergable. In other words, their contents do not make any sense to be attempted to be three-way merged, usually because they are completely rewritten every time and have no regions in common. (Perhaps because they're binary.)

  3. Files can't be ignored once they're checked in to the repository. If you have a merge conflict, because you've changed the file in two different branches, then you need to resolve that somehow. You could always take the theirs side of the merge, but you must act.

Upvotes: 1

Related Questions