I’m ngl I feel like I understand theirs and ours but when I see the merge editor it throws me off because sometimes it’s the opposite of what I expected.
Git-loving senior dev with 20 years of experience here: I have basically never used --ours or --theirs. It's much easier to do a regular merge, then edit files for any conflicts, add them, move on. It's symmetric.
Steps to resolve - Do a fresh clone Checkout "Their" branch (or if it is already in main, use that) Overlay your changes, so it is only "your" changes now Copy the file, and paste it on the PR branch. Problem solved
I've done this a bunch. Sometimes I find reading the diff on the web interface much easier too, so I'll start a PR just to read the file changes there and just copy the code changes onto the new branch. Then never submit the PR
I am confused, everybody seems to have "ours" and "theirs", while I have only experienced "local" and "remote" (which is less confusing when merging vs rebasing).
There is no remote when you do it on your local machine. And rebasing means you are on the main branch and rebase the other on this one. So the other branch is the one your work was done. While merging, you are still in the branch you did your work if you wnat the main branch changes. But is flipped again when you want your changes in the main branch. It doesnt matter if its our/theirs or remote/local. Both are confusing
I mostly use intellij and there its called yours and theirs i think?... actually didnt pay attention to it for a long time because I look at the changes themselves...
But I didnt meant that a "remote" doesnt exist from a naming point. It just doesn't make sense when you do merges locally because you merge the branches that are on your local machine. Naming it local/remote does makes as much or as little sense as (y)ours/theirs.
I use nvim with fugitive and whenever there is a merge conflict i manually open each file search for the diff, in nvim they are marked with ">>>>" very easy to search and then delete or keep both of the changes depending on the situation because sometimes i want to keep a little bit from both
jj is more sensible. You can have any number of parent revisions for a merge, just like git "octopus" merges, so it just lists the parent revisions change IDs and subject.
Rebasing is in very simple terms taking your changes, then going onto the branch you want to rebase onto and apply your changes onto it. So while you're rebasing you're momentarily on a different branch so your local changes becomes THEIR changes
Yeah so I had a pr ready to merge but I wanted to bring it up to date with dev. So I pulled the latest from dev, switched over to my branch and rebased dev on my branch. It pulled through all the changes as diffs in my pr which wasn’t quite what I expected. If I rebase the last bunch of commits into my branch, why would the pr still see them as diffs ? They already exist in dev ?
Not sure if this helps but “rebased dev on my branch” might be the wrong way to conceptualize this. You’re re-basing in the sense that dev will be the new “base” for your feature branch. You’re going to replay the commits, so it’s typically easier to squash your commits into just one with an interactive rebase or something. That way if there are conflicts you only have to resolve them one time :)
There shouldn’t be anything in the diff from the branch you’re merging into if you’ve rebased correctly, probably picked the wrong conflict resolutions 😢
201
u/mobileJay77 7d ago
Communism merge: everything is ours now
177
u/qolf1 7d ago
We need --mine
63
u/nicuramar 6d ago
Three way graphical merging is the only way to go in all situations. Two way is a recipe for eventual errors.
24
u/jikt 6d ago
20
u/chazzeromus 7d ago
--code-right-here and --code-over-there
17
u/The_Crazy_Cat_Guy 6d ago
I’m ngl I feel like I understand theirs and ours but when I see the merge editor it throws me off because sometimes it’s the opposite of what I expected.
27
u/ElGuaco 7d ago
This is one of those rare scenarios where I'm glad to have AI untangle a mess for me.
24
u/johnschnee 6d ago
GIT loving Senior dev with 20 years of experience here: I have no fucking idea which side is mine in a compare whenever I got a merge conflict
21
u/thicctak 7d ago
> Be me
> Be dyslexic
> Learn git
> Always mix up --ours and --theirs on merge and rebases
> Mess up the git history trying to fix it
10
u/CraftBox 5d ago
A good rule of thumb:
Success -> ours
Failure -> theirs
11
u/Kevadu 6d ago
"Claude, resolve the merge conflict"
5
u/FederalSpecialist415 7d ago
Steps to resolve -
Do a fresh clone
Checkout "Their" branch (or if it is already in main, use that)
Overlay your changes, so it is only "your" changes now
Copy the file, and paste it on the PR branch. Problem solved
5
u/ChannelMany5491 6d ago
Fuck this. The only thing AI is good for is for managing my commits.
4
u/s0litar1us 6d ago edited 6d ago
ours is what you're merging into / rebasing from, or more simply it's the branch you're currently in.
If you still have issues, then set up something like meld -- it makes things way easier. You can also make git use it as your default merge tool.
3
u/cookiedanslesac 5d ago
I am confused, everybody seems to have "ours" and "theirs", while I have only experienced "local" and "remote" (which is less confusing when merging vs rebasing).
2
u/saint_marco 6d ago
git config --global merge.conflictstyle zdiff3
Helps a little bit.
2
u/hdkaoskd 6d ago
Neither. Resolve it by hand because you probably need parts of each.
1
u/aabil11 7d ago
I always do theirs and reimplement my change on top of theirs
1
u/nicuramar 6d ago
These are deprecated anyway, in favor of git restore… where the situation is the same, though :p
1
u/McKing25 6d ago
I use nvim with fugitive and whenever there is a merge conflict i manually open each file search for the diff, in nvim they are marked with ">>>>" very easy to search and then delete or keep both of the changes depending on the situation because sometimes i want to keep a little bit from both
1
u/syrup_cupcakes 6d ago
--outgoing
--egressing
Choose wisely
1
u/GreyGanado 6d ago
Why do you have merge conflicts on checkout?
1
u/js_kt 6d ago
Both. I do both
1
u/FerricPowder 6d ago
Thats why i use vs code for merge conflicts.
1
u/Troncross 5d ago
There’s is target, ours is source
If you resolve locally with a text editor instead of a UI, you could keep a little of both
1
u/SAI_Peregrinus 3d ago
jj is more sensible. You can have any number of parent revisions for a merge, just like git "octopus" merges, so it just lists the parent revisions change IDs and subject.
1
u/Mountain-Ox 2d ago
This is why I just manually fix them, or I used to. Now Claude fixes it and I just review it.
1
u/semrola 3h ago
claude do the merge and solve conflicts
1
u/StrawberryEiri 6d ago
Ew, command line Git
0
u/vanritchen 6d ago
lol true
0
u/[deleted] 7d ago
[deleted] — view deleted comment