一、不同文件的暂存
$ git add -i
*** Commands *** 1: status 2: update 3: revert 4: add untracked 5: patch 6: diff 7: quit 8: help
What now> 2
Update>> 1,2 (选择要暂存的文件)
Update>>回车 (选中文件所有内容暂存)
二、同一文件不同部分暂存
$ git add -i
What now> 5
Patch update>> 1 (选择要暂存的文件)
Update>>回车 (按区块查看文件修改记录)
Stage this hunk [y,n,q,a,d,/,j,J,g,e,?]? n
y - stage this hunk
n - do not stage this hunk
a - stage this and all the remaining hunks in the file
d - do not stage this hunk nor any of the remaining hunks in the file
g - select a hunk to go to
/ - search for a hunk matching the given regex
j - leave this hunk undecided, see next undecided hunk
J - leave this hunk undecided, see next hunk
k - leave this hunk undecided, see previous undecided hunk
K - leave this hunk undecided, see previous hunk
s - split the current hunk into smaller hunks
e - manually edit the current hunk
? - print help