Ben*_*ngt 2 git git-add git-reset
我运行git add了一些文件,构成了一组逻辑上独立的更改,对它们进行了其他更改,并使用git add -p. 进行到一半时,我意识到我还没有提交前一组。
的交互式帮助git add -p仅提供以下选项:
Stage this hunk [y,n,q,a,d,/,s,e,?]? ?
y - stage this hunk
n - do not stage this hunk
q - quit; do not stage this hunk nor any of the remaining ones
a - stage this hunk and all later hunks in the file
d - do not stage this hunk nor any of the later 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
Run Code Online (Sandbox Code Playgroud)
如何重置已添加的补丁?
git add -p阶段更改不存储历史记录,可用于恢复添加。不过,您可以使用git reset -p或git reset --patch来取消暂存更改。程序看起来如下:
qgit add -pgit reset -pgit commitgit add -pgit commit