tags:

views:

42

answers:

2

Hi all. I have a git branch (called v4) that was made from master just yesterday. There were a couple of changes to master that i want to get into v4. So, in v4, i tried to do a rebase from master, and one file keeps screwing things up: a one-line text file that contains the version number. This file is app/views/common/version.txt, which before rebasing contains this text:

v1.4-alpha-02

Here's what i'm doing.

> git rebase master
First, rewinding head to replay your work on top of it...
Applying: new version, new branch
error: patch failed: app/views/common/version.txt:1
error: app/views/common/version.txt: patch does not apply
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Auto-merging app/views/common/version.txt
CONFLICT (content): Merge conflict in app/views/common/version.txt
Failed to merge in the changes.
Patch failed at 0001 new version, new branch

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To restore the original branch and stop rebasing run "git rebase --abort".

The version.txt now looks like this:

<<<<<<< HEAD:app/views/common/version.txt
v1.4-alpha-02
=======
v1.4-alpha-01
>>>>>>> new version, new branch:app/views/common/version.txt

So, i tidy it up so it looks like this:

v1.4-alpha-02

and then try to carry on: at first i try a commit:

> git commit -a -m "merged"
# Not currently on any branch.
nothing to commit (working directory clean)

No luck there. So, i try adding the file:

git add app/views/common/version.txt

No response. No news is good news i guess. So, i try to continue:

> git rebase --continue
Applying: new version, new branch
No changes - did you forget to use 'git add'?

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To restore the original branch and stop rebasing run "git rebase --abort".

It's at this point, after going round and round with this, that i'm banging my head off the desk. What's going on here? What am i doing wrong? Can anyone set me straight?

thanks, max

EDIT - for unutbu

I changed the file as you suggested and get the same error:

> git rebase master
First, rewinding head to replay your work on top of it...
Applying: new version, new branch
error: patch failed: app/views/common/version.txt:1
error: app/views/common/version.txt: patch does not apply
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Auto-merging app/views/common/version.txt
CONFLICT (content): Merge conflict in app/views/common/version.txt
Failed to merge in the changes.
Patch failed at 0001 new version, new branch

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To restore the original branch and stop rebasing run "git rebase --abort".
A: 

Change app/views/common/version.txt to

v1.4-alpha-01

At this point in the rebase, remember that you are resolving merge conflicts to show the progression of the non-master branch.

So, in rebasing from

      A---B---C topic
     /
D---E---F---G master

to

              A*--B*--C* topic
             /
D---E---F---G master

the conflict you are resolving is in how to create A* on the topic branch.

So after doing git rebase --abort, the commands should be

git checkout topic
git rebase master
< make edits to resolve conflicts >
git add .
git rebase --continue

If that doesn't work, then I'm sorry, my answer must not be what you are looking for. There might be some other issue of which I'm not aware (due to my own lack of knowledge).

unutbu
Thanks unutbu, i tried that but no luck: see OP for new edit. cheers
Max Williams
A: 

The behavior you're seeing is not what I would expect from a typical rebase with just this conflict. Consider using a separate branch to do this rebase (especially if you've already pushed the commits remotely that you're fast-forwarding). Also, git mergetool can be helpful for resolving conflicts and remembering to issue a git add.

In this minimal example, the rebase works as expected. Can you provide an example that shows the behavior you're seeing?

#!/bin/bash

cd /tmp
mkdir rebasetest
cd rebasetest
git init
echo 'v1.0' > version.txt
git add version.txt
git commit -m 'initial commit'
git checkout -b v4
echo 'v1.4-alpha-01' > version.txt
git add version.txt
git commit -m 'created v4'
git checkout master
git merge v4
echo 'v1.4-alpha-01-rc1' > version.txt
git add version.txt
git commit -m 'upped version on master to v1.4-alpha-01-rc1'
git checkout v4
echo 'v1.4-alpha-02' > version.txt
git add version.txt
git commit -m 'starting work on alpha-02'

git rebase master
echo 'v1.4-alpha-02' > version.txt
git add version.txt
git rebase --continue
Ben Taitelbaum