假设有几个文件被修改,我只想要每次提交一个文件.怎么做?给出一个状态示例如下所示.谢谢!!
例如:
> git status
# modified: file01.txt
# modified: file02.txt
# modified: file03.txt
# modified: file04.txt
# modified: file05.txt
Run Code Online (Sandbox Code Playgroud)
daf*_*daf 46
Use git add -p
followed by git commit
. git add -p
asks you for each change whether to stage it for committing, which is super convenient.
You can also use -p
with git reset
and git checkout
.
Ale*_*ner 20
有几种方法,但最简单的可能是:
git commit file01.txt
git commit file02.txt
...
Run Code Online (Sandbox Code Playgroud)
您提交命令后列出的所有路径都将被提交,无论它们是否已提交.或者,您可以暂存每个,然后提交:
git add file01.txt
git commit
git add file02.txt
git commit
...
Run Code Online (Sandbox Code Playgroud)
phi*_*ils 14
git add -p
由daf的回答描述很好,但是对于更直接的选择和选择方法,我真的很喜欢:
git add -e
它会生成相应的补丁,然后将其加载到首选编辑器中,以便您可以根据需要进行编辑.保存文件并退出编辑器时,只有编辑后的修补程序版本所做的更改才会添加到索引中.
如果您不小心关闭了编辑器而没有进行更改,您可能想要使用get reset HEAD
然后重新开始.
归档时间: |
|
查看次数: |
19397 次 |
最近记录: |