Fix hunks from git add -i?

Is it possible? It would be nice if I didn't have to switch between the git-add-i and git commands when breaking hunks into different commits. Is there a better way to do this? Or am I doing something wrong?

+4
source share
1 answer

As described in the git book , a simple git commit is still required after a git add --interactive .
(With the following warning:

Remember that you should not run ' git commit -a ', which will sweep away all the cautious changes you made and just commit everything)

Note: maybe git add -p ( --patch ) will be a little more convenient:

Interactively select patch fragments between the index and the working tree and add them to the index. This allows the user to see the difference before adding the changed content to the index.

This effectively launches add --interactive , but bypasses the initial command menu and directly jumps to the patch subcommand .


Bonus, with Git 2.24 (Q4 2019), " git add -i " taught to show the total number of blocks and blocks that have been processed so far when displaying prompts.

See commit 8085050 (September 30, 2019) from Kunal Tyagi ( kunaltyagi ) .
(Merged by Junio ​​C Hamano - [TG48] - in commit f0d407e , 11 Oct 2019)

add -i : show progress counter in tooltip

So, although you still need a separate commit step, at least you know how far you have come up with the completion of the git add interactive session / patch.

+3
source

Source: https://habr.com/ru/post/1309384/


All Articles