利用:
git add --interactive
我在 ~/.bashrc 中为它创建了一个别名:
alias gi='git add --interactive'
了解如何让我们充分发挥 git add -i 的潜力。它现在是我日常工作流程的一部分,也是我最喜欢 git 的地方之一!:)
其他答案隐藏了 git add -i 的其他不错的功能:
-p, --patch
Interactively choose hunks of patch between the index and the work tree
and add them to the index. This gives the user a chance to review the
difference before adding modified contents to the index.
This effectively runs add --interactive,
but bypasses the initial command menu
and directly jumps to the patch subcommand.
See “Interactive mode” for details.