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.
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 -pbehavior of patching all files.Find your copy of
git-add--interactiveand 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.
Another possible point of change would be at the very bottom of the file. You can change
$patch_modeto 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.