2

I pulled from origin main, and I'm having issues handling conflicts on my branch.

I did the following

git checkout test (name of my branch) git pull origin main 

It tells me I have conflicts and is asking me to fix conflicts and call git rebase --continue or git rebase --abort.

I get the following error:

Auto-merging .circleci/config.yml
CONFLICT (content): Merge conflict in .circleci/config.yml
error: could not apply 2b7a15bfe61b... fix

I did the following

git checkout --ours .circleci/config.yml git add .circleci/config.yml git rebase --continue 

but I keep getting this error:

Auto-merging .circleci/config.yml
CONFLICT (content): Merge conflict in .circleci/config.yml
error: could not apply 62df6154b7da... fix

and the cycle continues.

What can I do? I'm in rebase hell

9
  • I might be asking a question that is assumed, but just make sure - you have opened .circleci/config.yml and editted out the <<<<<<< HEAD one version ========== other version >>>>>>> test conflict? I ask because your question does not mention attempting to resolve the conflict. Your question is how to stop the SCM doing this, so it might be premised on there should not be a conflict, how to make git act correctly. Commented Oct 2 at 18:40
  • 1
    @ChrisMaxwell They did git checkout --ours .circleci/config.yml and git add .circleci/config.yml to resolve the conflict, i.e. choosing one version and discarding the other version. Commented Oct 2 at 18:40
  • Apart from the merge conflict you're having, I don't think that git checkout test followed by git pull origin main yields the result you expect. In fact, git pull fetches the upstream's branch main and then merges (or rebases depending on your configs) the branch currently checked out. So, in your case the remote's main changes are being applied to test, not your local main. Is that really what you want? Commented Oct 2 at 18:55
  • I resolved the problem by doing git rebase --abort then git merge main. What do you guys think of that solution? Commented Oct 2 at 18:59
  • @dani-vta (assuming pull.rebase is configured) git checkout test and then git pull origin main should rebase test onto origin/main, shouldn't it? Commented Oct 2 at 19:12

1 Answer 1

2

Your intuition of choosing --ours for using your version of the file was right, however, as the documentation of git checkout says:

Note that during git rebase and git pull --rebase, ours and theirs may appear swapped; --ours gives the version from the branch the changes are rebased onto, while --theirs gives the version from the branch that holds your work that is being rebased.

So you can git rebase --abort and try again with --theirs instead of --ours this time.

Sign up to request clarification or add additional context in comments.

1 Comment

Turns out it was not rebase hell, just rebase purgatory :-)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.