I'm having git conflict while doing a rebase. I want to keep both the files from mine and theirs... Is there any way to resolve it and keep both the files?
Asked
Active
Viewed 62 times
2 Answers
0
git stash
your local change.git rebase
git stash pop
get your change- fix local conflict
- push

PatrickChen
- 1,350
- 1
- 11
- 19
-
Git stage, or git stash? – Prannay Bothra May 08 '20 at 13:07
-
Well I have resolved it manually... First use mine and then use theirs... And I saved both the files – Prannay Bothra May 08 '20 at 13:08
-
typo, stash, there is previous post: https://stackoverflow.com/questions/11709885/git-rebase-merge-conflict – PatrickChen May 08 '20 at 13:30
0
You note that:
I have resolved it manually...
In fact, any resolution is manual, by definition. Git tried to resolve it automatically and failed, and stopped in the middle of the rebase. Your job is to resolve the problem. Whatever you do, Git assumes that's the right resolution. :-) Whatever you did, you did "manually".
First use mine and then use theirs... And I saved both the files
If you mean:
git checkout --ours path/to/file
cp path/to/file path/to/file.ours
git add path/to/file.ours
git checkout --theirs path/to/file
git add path/to/file
for instance, that's a correct way to keep the "ours" version under a new name and tell Git that path/to/file
should use the the "theirs" version as the resolved file.
In any case, whatever you did, Git will assume that this is the correct resolution of the problem: when Git's automatic merge fails, Git relies on you to know the right answer.

torek
- 448,244
- 59
- 642
- 775