vim

dharrigan 2023-02-08T14:31:58.025739Z

Users of vim-fugitive...say I want to revert a particular diff hunk to the checked out version, I know that I can do Git diff % to show the diffs in the file. Any magic incantation to go to a particular diff hunk and say "ignore all that, give me what it was originally" and thus revert that particular bit of the file?

dharrigan 2023-02-10T08:19:57.806689Z

Oh, I do use that and I did forget about that!

emilaasa 2023-02-10T14:12:18.031549Z

and <leader>hp to get a preview

emilaasa 2023-02-10T14:12:27.657839Z

or post-view I guess šŸ™‚

daniel.flexiana 2023-02-10T15:01:21.514809Z

hs stages

sheluchin 2023-02-08T19:49:16.459879Z

If I understand correctly, you can open the status window with :Git, expand the file of interest with =, navigate to your hunk, do a visual line selection, and then use X to revert it.

šŸ™Œ 1
daniel.flexiana 2023-02-08T20:07:19.186849Z

Nice! I wasn't aware you can do a visual select. I usually just type X and the hunk gets reverted. Also you can type I and then split the hunk in case you want

emilaasa 2023-02-10T03:46:21.248859Z

I use https://github.com/airblade/vim-gitgutter#getting-started for what I think you are describing - <leader>hu

dominicm 2023-02-08T14:49:12.907519Z

Gdiffsplit then dp or dg?

dharrigan 2023-02-08T16:00:20.054539Z

Party time!

2023-02-08T18:37:43.152139Z

looks like there is the dd shortcut for that as well

dominicm 2023-02-08T14:49:31.653049Z

(I did this 5m ago!)

dave 2023-02-08T15:38:46.211019Z

I don't use vim-fugitive, but just to offer an alternative: • Use git add --patch (or if fugitive lets you do something similar, you can use that) to stage all the parts that you do want to keep. • Make a commit to ensure you don't lose that part. • Use git checkout path/to/the-file-in-question to revert to the checked-out version of that file.

dharrigan 2023-02-08T16:00:37.491629Z

Ta šŸ™‚

Amit Gold 2023-02-09T09:40:20.039929Z

I’m late to the party, but X on a hunk in fugitive discards that hunk.

Amit Gold 2023-02-09T09:40:32.175429Z

X on a file discards changes to the whole file