Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conflict resolver, pick all from branch/stash #2026

Open
nagylzs opened this issue Jul 5, 2022 · 10 comments · May be fixed by #3477
Open

conflict resolver, pick all from branch/stash #2026

nagylzs opened this issue Jul 5, 2022 · 10 comments · May be fixed by #3477
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@nagylzs
Copy link

nagylzs commented Jul 5, 2022

Is your feature request related to a problem? Please describe.

Sometimes when I merge two branches (or a branch and a stash), there are a few files that have lots of conflicts. A good example would be a package-lock.json file. If the two branches are diverged a long time ago, then there can be hundreds of conflicts within that file. Currently, the only available commands are "b: pick all hunks" and "space: pick hunk". I have tried to use "b" to "pick all hunks that are from branch X" or "pick all hunks that are from stash Y" but it does not work that way. I have to go over all hunks and manually pick each of them with "b".

Describe the solution you'd like

When the conflict is a result of merging or rebasing branch X with branch Y, or branch X with stash Y, then there should be an option to accept the complete file version from either X or Y, without going through the hunks.

@nagylzs nagylzs added the enhancement New feature or request label Jul 5, 2022
@jesseduffield
Copy link
Owner

jesseduffield commented Jul 5, 2022

Good idea. I suppose if it's going to apply to the whole file, then the keybinding should be on the file itself rather than being in the merge panel (it can be both of course).

Do we know if git already provides some CLI functionality to do this? I'm thinking something like git reset Y -- <path> to get what's on branch Y

@nagylzs
Copy link
Author

nagylzs commented Jul 5, 2022

I think the command is:

git checkout f08a63ff4fa7b8479f8c698e5998ee1afcac3a4e file_name

but I'm not sure how it can be done with a file that is inside a stash

@nagylzs
Copy link
Author

nagylzs commented Jul 5, 2022

Yes, a keybinding on the file would be great.

@pr-313
Copy link

pr-313 commented Jul 13, 2022

Could we possibly use git checkout --theirs path/to/file/under/cursor as a keybind during merge conflicts? If so how can we access the aforementioned path to "file under cursor"

@mark2185
Copy link
Collaborator

@pr-313 I believe this should help.

So it's {{.SelectedFile.Name}}?

@linde12
Copy link

linde12 commented Oct 10, 2023

i use this a lot for lock files, git checkout --theirs and git checkout --ours would be sweet to have as keybinds

@jesseduffield
Copy link
Owner

Having a menu which includes git checkout --theirs <path> and git checkout --ours <path> would be great. I actually had a need for this today. The question is: where do we put it? Some options that come to mind:

  • add the items to the existing 'rebase options' menu which you get by pressing 'm'. Only include the items if a file is selected
  • replace the git merge tool confirmation prompt (which you get by pressing 'shift+M') with a menu which contains the git merge tool option as well as the two new options.

I think we should go with the second option.

I'll chuck a good-first-issue label on this cos it should be easy to implement.

Any chance you're up to the task @linde12 (or @pr-313 / @nagylzs )?

@jesseduffield jesseduffield added the good first issue Good for newcomers label Oct 11, 2023
@linde12
Copy link

linde12 commented Oct 11, 2023

@jesseduffield
would love to get into go again, but unfortunately time is not on my side right now - ill have to pass on this one

@pr-313
Copy link

pr-313 commented Oct 11, 2023

I'd like to give it a shot!

@GitMurf
Copy link

GitMurf commented Feb 14, 2024

any progress here? I have a lock file with hundreds of changes to merge between. is the only option currently to use a cli command? Thanks!

recht added a commit to recht/lazygit that referenced this issue Apr 5, 2024
…l there

Also add options for `git checkout --theirs` and `git checkout --ours`

Fixes jesseduffield#2026
recht added a commit to recht/lazygit that referenced this issue Apr 5, 2024
…l there

Also add options for `git checkout --theirs` and `git checkout --ours`

Fixes jesseduffield#2026
recht added a commit to recht/lazygit that referenced this issue Apr 7, 2024
…l there

Also add options for `git checkout --theirs` and `git checkout --ours`

Fixes jesseduffield#2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants