threads / discuss / 35818

Rebase fail with new file

Subject: Rebase fail with new file

## tl;dr

One message between Feb 6, 2014 and Feb 6, 2014.

replies: 0people: 1as markdown or json

Lee Carver· Feb 6, 2014, 20:11 UTC · lore
GitDev -

During a rebase of a feature branch to the master branch, I lost a new file in a new directory. I was able to recover by replaying the rebase and taking exceptional actions. However, I'm left with the impression the git does not handle new files properly under some rebase situations and gives the wrong advice to users.

I was able to recover by reseting the branch to the pre-rebase commit, repeating the rebase, and manually applying the .git/rebase-apply/patch at the critical point. I do not understand why the patch did not work through the rebase command.

Additionally, the git recommendation that after the failed patch, with no local changes, a [git rebase --skip] is a likely resolution is just wrong. Skipping after a complete patch failure lead me to very broken working directory.

Details follow, and the contents of the problematic commit are attached (from [git show 2e9b460]).

Thanks
   Lee
This occurs with git version 1.8.3.2
[1024] $ git --version
git version 1.8.3.2
*** Details ***

Initial setup: After working in branch feature/build-projects for several days (with ~21 commits+pushes from branch point), I needed to integrate new changes from the master branch. Here are the steps from my bash history:

  879  git checkout master
  880  git pull
  881  git checkout feature/build-projects
  882  git rebase master

There were a couple of conflicts, which I resolved and moved on with [git rebase --continue].

At approximately the 14th commit, the rebase stopped with this message:
<bash>
Applying: STRY0057770: Add -Z parent for late build modules.
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
error: Your local changes to the following files would be overwritten by merge:
glide-app-itbm/pom.xml
Please, commit your changes or stash them before you can merge.
Aborting
Failed to merge in the changes.
Patch failed at 0014 STRY0057770: Add -Z parent for late build modules.
The copy of the patch that failed is found in:
   /Users/lee.carver/Service-now/dev/glide04/git/glide/.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".
</bash>

Git status indicated no change, and inspection of the glide-app-itbm/pom.xml showed no conflicts or unexpected content:

<bash>
[888] $ git status
# HEAD detached from ee6d51c
# You are currently rebasing branch 'feature/build-projects' on 'ee6d51c'.
#   (all conflicts fixed: run "git rebase --continue")
#

When I tried to [git rebase --continue], the error message provided a little more information. Specifically, it mentions the added (new) file glide-module-parent-z/pom.xml.

[904] $ git rebase --continue
Applying: STRY0057770: Add -Z parent for late build modules.
Applying: STRY0057770: Provide version properties for diagrammer and
email-notification.
Using index info to reconstruct a base tree...
M glide-app-itbm/pom.xml
A glide-module-parent-z/pom.xml
Falling back to patching base and 3-way merge...
Auto-merging glide-module-parent/pom.xml
Auto-merging glide-app-itbm/pom.xml
CONFLICT (content): Merge conflict in glide-app-itbm/pom.xml
Failed to merge in the changes.

Patch failed at 0015 STRY0057770: Provide version properties for diagrammer and email-notification.

The copy of the patch that failed is found in:
   /Users/lee.carver/Service-now/dev/glide04/git/glide/.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".
</bash>

I made a minor edit to the glide-app-itbm/pom.xml (adding a "-z" to the parent name), [git add -u], and then [git rebase --continue].

There were a couple of addition conflicts, some resolved with --continue, some with --skip.

In the end, I was left with a working direction that did not contain the new file glide-module-parent-z/pom.xml or other changes from the problematic commit/rebase step (STRY0057770: Add -Z parent for late build modules.).

*** Recovery ***

I was able to recover the branch, and complete the rebase with the expected results only by manually applying the patch file at the critical rebase step:

Starting in the feature branch, these actions were performed:
  928  git reset --hard 6793d9f
  930  git checkout master
  931  git pull
  932  git checkout feature/build-projects
  934  git rebase master

When the rebase of (STRY0057770: Add -Z parent for late build modules.) stopped, I manually applied the patch

  959  git apply .git/rebase-apply/patch

With the appropriate adds, etc. I was able to [git rebase --continue] to a successful conclusion.

← back to recent threads