I find the use of git add --patch very useful for my work-flow sometimes, like when I need to revise lots before anything is ready to commit, especially with documentation. If I have a large number of hunks to sift through, the search feature via / is helpful, but I have not discovered any way to search for the next hunk matching my regex without retyping the regex each time. Is there a way to do that?
Asked
Active
Viewed 290 times
2 Answers
1
git add
is not a bash shell so you can't just recall history. Just copy the regex to your clipboard before executing it. You can then paste it in next time.

Adam Dymitruk
- 124,556
- 26
- 146
- 141
-
1I was hoping for something built-in and less tedious, like how **n** works in vi or maybe just hitting Enter at the "search for regex?" prompt (which does not work). – JFlo Jul 16 '12 at 18:17
-
1Unfortunately that doesn't exist. You have a very specific use case. I'm not sure if that will ever make it as a feature of the current `patch` mechanism. Perhaps if git gets another mechanism for patch additions via bash itself we'll be able to just up-arrow to what we did before. There's value in what you want. – Adam Dymitruk Jul 16 '12 at 18:20
-
1Well knowing the feature doesn't exist is better than wondering if I've overlooked something. I originally checked the man page to see if there was a command-line option to auto-select all hunks matching a regex -- that would be slick. – JFlo Jul 16 '12 at 18:37