Brian Low
Brian Low

Reputation: 11811

Automatically merge with union strategy during rebase

I want to automatically merge .csproj files when doing git rebase by keeping all added lines:

mkdir example
cd example

git init
echo "*.csproj text merge=union" > .gitattributes
echo "hello" > sample.csproj
git add -A
git commit -m "initial commit"

git branch test
git checkout test
echo "from test" >> sample.csproj
git add -A
git commit -m "from test"

git checkout master
echo "from master" >> sample.csproj
git add -A
git commit -m "from master"

git rebase test

There are two problems. First, this fails with a binary warning :

Falling back to patching base and 3-way merge...
warning: Cannot merge binary files: sample.csproj (HEAD vs. from master)
Auto-merging sample.csproj
CONFLICT (content): Merge conflict in sample.csproj
Failed to merge in the changes.

The second problem is on my other repo it correct determines the file is text (not sure why) but still fails the merge.

Falling back to patching base and 3-way merge...
Auto-merging Source/App/TRPS.Build/TRPS.Build.csproj
CONFLICT (content): Merge conflict in Source/App/TRPS.Build/TRPS.Build.csproj
Failed to merge in the changes.

Upvotes: 2

Views: 604

Answers (0)

Related Questions