0

I'm trying to rebase a feature branch on top of my develop branch, but I get the error below. I'm not sure, but I think this happens whenever I move files from one folder to another. Those files that it's complaining out didn't have any changes made in the branch that I'm rebasing on top of so I'm not sure what the problem is. This occurred originally in git 2.2.2; I just tried upgrading to 2.5.0 and it's still happening.

If I forget about the rebase and just merge my feature branch into the develop branch then everything works fine. Git has no problem merging the feature branch with the develop branch.

Does anyone have any suggestions on how I can complete the rebase? I tried using the git rebase --skip option, but that resulted in a bunch of code (from other commits presumably) getting deleted.

First, rewinding head to replay your work on top of it...
Applying: Entries now populate the Schedule A table when a calendar day is  clicked; other refactoring
Applying: Introduce DailyLog
Using index info to reconstruct a base tree...
<stdin>:37: trailing whitespace.
    @function_groups = current_user.organization.visible_function_groups
<stdin>:82: trailing whitespace.
    if @entry.save
<stdin>:111: trailing whitespace.
    # for a given day.
<stdin>:136: trailing whitespace.
    self.create(user: user, created_at: the_date_time, organization_id: user.organization.id,
<stdin>:383: trailing whitespace.
      </div>
warning: squelched 13 whitespace errors
warning: 18 lines add whitespace errors.
Falling back to patching base and 3-way merge...
error: Your local changes to the following files would be overwritten by merge:
    app/views/entries/_entry_form_activity.html.erb
    app/views/entries/_entry_form_employee_info.html.erb
    app/views/entries/_entry_form_other_info.html.erb
    app/views/entries/_entry_form_production_info.html.erb
    app/views/entries/_entry_form_time_codes.html.erb
    app/views/entries/create.js.erb
    app/views/entries/edit.html.erb
Please, commit your changes or stash them before you can merge.
Aborting
Failed to merge in the changes.
Patch failed at 0002 Introduce DailyLog
The copy of the patch that failed is found in:
    /home/slopeuser/Documents/dev/estat/.git/rebase-apply/patch

When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".
CodeSmith
  • 2,133
  • 1
  • 20
  • 43
  • Did you have your working directory clean? The error is telling you that git is finding files that are not committed and they would be lost. – blashser Aug 26 '15 at 22:55
  • Yah that's what the error sounds like to me too. Both the develop and feature branch were checked via `git status` and there are no uncommitted changes. – CodeSmith Aug 27 '15 at 03:07
  • Yes, but you can have these files in your `.gitignore` (I am guessing) you do not see them in a `git status` but they exist. Then when git tries to create these files, it reports the error. Try this: Clone your repo with the two branches and try the rebase in a new "clean" repo. – blashser Aug 27 '15 at 06:38

2 Answers2

1

Looks like you might have some whitespace errors, your differ to resolve it probably is ignoring whitespace, try to find the "show whitespace" setting for the differ you are using.

You can try to let git handle the issue by tinkering with the white space settings, see here for a similar question: git, whitespace errors, squelching and autocrlf, the definitive answers

Community
  • 1
  • 1
Willem D'Haeseleer
  • 19,661
  • 9
  • 66
  • 99
  • I don't think that's the issue. I looked at your link and added a config option to fix the whitespace issue. Git it now fixing the whitespace problems, but it's still failing. I think this is the more important line `error: Your local changes to the following files would be overwritten by merge:` The rebase doesn't seem to like the fact that the develop branch wants to reintroduce files that were moved in the feature branch. – CodeSmith Aug 27 '15 at 01:34
0

I'm still not sure why the rebase is failing, but I think I might have found a workaround after looking over the rebase documentation. It turns out you can pass a merge strategy to the rebase commmand via the -s option.

I cancelled the currently failing rebase by doing:

git rebase --abort

And then reran the rebase using a different merge strategy:

git rebase develop -s resolve

All commits rebased as expected this time.

CodeSmith
  • 2,133
  • 1
  • 20
  • 43