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

Do we have something like "custom patch" in tig? #1278

Open
MartyLake opened this issue Apr 18, 2023 · 3 comments
Open

Do we have something like "custom patch" in tig? #1278

MartyLake opened this issue Apr 18, 2023 · 3 comments

Comments

@MartyLake
Copy link

Hey, I stumbled upon a demonstration of lazygit, most of it I could already do with tig.

There was this concept called "custom patch"
https://github.com/jesseduffield/lazygit/wiki/Directly-Changing-Code-Stored-In-Commits#lazygit-solution , where one has this temporary diff space and shortcut command to apply the patch to a former commit.

If I had to do it with vanilla git, I would do git add -p, then git diff --staged > patch.diff, then git rebase -i %(commit), then edit the TODO to edit this commit (this I don’t know how to do programmatically), then git apply patch.diff and finally git rebase --continue.

I wonder how it could be emulated in tig, specifically this rebase interactive+edit todo in one script.

Best,

@MartyLake MartyLake changed the title Do we have something like "custom patch" in tig: Do we have something like "custom patch" in tig? Apr 18, 2023
@MartyLake
Copy link
Author

I don’t know how they do it, but you can do "custom patch" of commits that you have already done.

@krobelus
Copy link
Contributor

krobelus commented Jun 3, 2023

Tig doesn't have dedicated support for this feature yet; I think it would be a nice feature.
In the diff view, pressing u could add the selected hunk to a per-commit index. It should be possible to add this special index to an earlier or later commit, or create a separate commit for it.

For the time being, I suggest using git-revise, another 3rd party tool. I sometimes use these bindings to split commits:

bind generic avc >git revise --cut %(commit)
bind generic avC >git revise --cut %(commit) -- %(file)

the second one extracts only from the selected file (though that PR is not merged yet)

@MartyLake
Copy link
Author

@krobelus Thank you very much, I never heard of git revise before, will definitely try to use it !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants