-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Revert selected lines context option #3159
Comments
Hi, there is one place where the "revert selected" is missing: in the diff window, file context menu, the user can right click on a file and select "Cherry-pick file's changes" but there is no "Revert selected file's changes" option. The only way to perform this action is to reverse the order of the diff (select the child first then the parent) and then cherry-pick the file changes (so, one is actually cherry-picking the reverse diff changes), which is not very intuitive. |
@PierrotG It was added in the 2.50 version. |
@jbialobr
There is no "Revert file's changes" listed, and, as I commented before, it would be nice to have it, the same way we get "Revert Commit" for commits and "Revert selected lines" for individual chunks. |
Ok, you are right, I misread your comment, having the issue title in mind. Since 2.50 you can select a file and then select all changes in the file's diff view and choose from the context menu to revert the selected lines. |
"Reset file(s)..." allows you to revert to the previous commit. |
Is there a regression or am I looking at the wrong place? I select a commit, select a file in the "Diff" tab and right click on any of the changed lines (with and without selecting a range of text), but there is no "Revert" option. The first two available options are "Stage selected line(s)" and "Reset selected line(s)" which don't seem to make much sense here. And they either cause a "patch failed" error or make some local changes before immediately triggering a merge conflict. |
This was changed in 3.0 or so. |
I see, thank you. So "Reset selected line(s)" should be what I'm looking for. But there's still the issue of the constant "error: patch failed" when trying to reset lines from commits. Although, at least when there are no changes yet in that file, it actually stages the reverted lines despite the error. But reverting more changes from that file mostly doesn't fails with the same error. But that's probably a different issue. At least now I know how it should work. |
@Frettman this feature doesn't play well when the diff is displayed with some 'ignore whitespace changes'. When you want to use it, most of the time, disabling it before resetting the changes is the way to go... I think that's the problem you have... |
Unfortunately I have tried that already; even "Show entire file". I have tried resetting one-liner changes from the latest commit (to definitely avoid conflicts with any intermediate commits), but it's still the same. I have tried a fresh install on a new machine. I have also verified that the file encoding is correct. I have checked line endings (it's LF with Git configured to core.autocrlf to "input"). No idea what else to check. |
Try it in reverse - unstage the file completely, and then only stage what's relevant. |
The context is reverting individual lines from a commit, where there is no unstage? Unless you mean resetting the whole file and then resetting all the staged changes I don't want to revert. That's the workaround the OP used back in 2016 and yes, it's still valid :) |
If the Git retry works, the popup is removed in 4.0. The reset/stage handling works by creating the equivalence of patchfiles, so if a patchfile would file, the line patching will fail. The algoritm when applying patches could still be tuned and let GE retry some more. The patching requests that Git "tries its hardest" but then Git requires that a file is identical in worktree and index "commits". So there could be separate attempt if the first try failed. Regardless what is can be done with these patches: Sometimes you know better how to apply the changes, use an external difftool then. |
When viewing a commit, I'd like to be able to select lines from that commit and have an option in the right-click context menu for "Revert selected lines".
What I currently do for this is to revert the commit, then stage those lines and remove the rest.
Just like cherry pick, the default should be to make staged changes out of the lines, with a checkbox for "Automatically commit".
The text was updated successfully, but these errors were encountered: