Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git rebase with overwrite

Tags:

git

git-rebase

I am trying to get my master changes into my local branch by doing

git checkout MyPersonalBranch
git rebase master

then I get the error

 Patch failed at ..blah blah
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".

When I try git rebase --continue I get the error

xxx.client.jar: needs merge
You must edit all merge conflicts and then
mark them as resolved using git add

I want it to keep the xxx.jar in MyPersonalBranch. How do I tell git not to try to merge this one file?

like image 753
developer747 Avatar asked Nov 02 '25 23:11

developer747


1 Answers

In general, you can use the --strategy option to specify how conflicts should be handled. The strategy theirs blindly replaces files.

However, in your case, you've only got a single file. You really won't want to use the theirs strategy for all files. Instead, after you get the message to resolve the conflict, you can checkout that one specific file from the branch:

git checkout <branch> yourfile

(At that point, <branch> still refers to the branch as it was before the rebase started.)


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!