Reputation: 3042
How can I get "git add -i" to start up in patch mode directly without having to type "5" + Enter?
I know about "git add -p", but it's not the same as it doesn't show me a list of files to select from first.
This is very annoying because I'd like to jump between "git add -i" and "git commit" very quickly to turn my dirty tree into some nice looking commits.
Upvotes: 3
Views: 208
Reputation: 4014
It's a fairly easy change on a perl file to make this happen. I would only recommend doing this if you don't like the default git-add -p
behavior of patching all files.
Find your copy of git-add--interactive
and open with your favorite editor. Go to the patch_update_cmd subroutine. In there, there is an if statement which tests $patch_mode
. Remove the top part of the if statement or set it so that the conditional always evaluates to false. Save and test.
An example of what I did to make this work follows.
if (0) {
@them = @mods;
}
else {
@them = list_and_choose({ PROMPT => 'Patch update',
HEADER => $status_head, },
@mods);
}
Another possible point of change would be at the very bottom of the file. You can change $patch_mode
to some false value after the if statement, the effect should be the same.
Note you may have some issues if you're using a package manager or something else similar which tracks installed packages, I'm not sure.
Upvotes: 3
Reputation: 893
What you could do, is 'git add -p' and add the filenames as commandline arguments. with good tab completion (which only completes dirty files) it's about as effective as picking them from the menu.
Upvotes: 1