Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git rebase with conflict not work

Tags:

git

rebase

I have remote repository. I do:

git clone https://[email protected]/mylogin/myrepo.git

Clone success. I have git tree:
C(master)
|    B:A
|   /
B /
|
A
|
A0
|
A01(origin/head)(origin/master)
|
(some commits)

I need:
                B:A
C(master) / 

I need rebase branch B to C(master) What I do:

git checkout b1
Switched to branch 'b1'
git rebase master
First, rewinding head to replay your work on top of it...
Applying: B:A
Using index info to reconstruct a base tree...
M   index1.txt
Falling back to patching base and 3-way merge...
Auto-merging index1.txt
CONFLICT (content): Merge conflict in index1.txt
Failed to merge in the changes.
Patch failed at 0001 B:A
The copy of the patch that failed is found in:
   /pth/to dir/.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".

git branch
* (no branch)
  b1
  master

What must I do? I can switch in branch b1, resolve conflict and commit, but it not help (I tested it).

like image 491
DenisOgr Avatar asked Oct 18 '13 08:10

DenisOgr


1 Answers

Git will stop rebasing if it detects conflicts it cannot automatically resolve. In your case, you have a conflict in the file index1.txt (you can see it in the output, and later on as well when running git status). You must fix the conflicts before continuing. Edit the file, and you'll see <<<<<<, ====== and >>>>>> markers. The conflict is in those lines, where what's between the < and the = is the changes in master, and after that (until the >) is the changes in branch b1. Fix it, remove the git markers (<,=,>), then run git add index1.txt, and move on to the next file (if you have any, in this example only index1.txt conflicts). Once you're done adding all files, run git rebase --continue. If git encounters another conflict, simply repeat the process for each file(s) it has problems with. Once you're done, git will tell you that rebase has successfully finished, and you'll be back on branch b1. If you want to stop the process and return to the original b1 (before the rebase command), simply run git rebase --abort.

Remember that when you fix conflicts, don't edit the file to be as it should be in your final commit, rather only introduce the changes you wanted for that specific commit. Other changes will be added as git continues rebasing and applying your commits.

like image 191
micromoses Avatar answered Nov 05 '22 00:11

micromoses