How to get "their" changes in the middle of conflicting Git rebase? How to get "their" changes in the middle of conflicting Git rebase? git git

How to get "their" changes in the middle of conflicting Git rebase?


You want to use:

git checkout --ours foo/bar.javagit add foo/bar.java

If you rebase a branch feature_x against main (i.e. running git rebase main while on branch feature_x), during rebasing ours refers to main and theirs to feature_x.

As pointed out in the git-rebase docs:

Note that a rebase merge works by replaying each commit from theworking branch on top of the branch. Because of this, whena merge conflict happens, the side reported as ours is the so-farrebased series, starting with <upstream>, and theirs is the workingbranch. In other words, the sides are swapped.

For further details read this thread.


If you want to pull a particular file from another branch just do

git checkout branch1 -- filenamefoo.txt

This will pull a version of the file from one branch into the current tree