如何使用Git一次提交一个文件? [英] How to commit one file at a time using Git?

查看:95
本文介绍了如何使用Git一次提交一个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设有多个文件被修改,我只想每次提交一个文件。怎么做?给出一个状态如下的例子。感谢!!



例:

 > git status 
#modified:file01.txt
#modified:file02.txt
#modified:file03.txt
#modified:file04.txt
#modified:file05 .txt


解决方案

有几种方法,但最简单可能是:

  git commit file01.txt 
git commit file02.txt
...

在提交命令之后列出的任何路径将被提交,无论它们是否被分阶段提交。或者,你可以将每一个阶段,然后提交:

  git add file01.txt 
git commit

git add file02.txt
git commit

...


Say there are several files modified and I just want one files committed each time. How to do that? Given an example with status looks like below. Thanks!!

Ex:

> git status
#   modified: file01.txt
#   modified: file02.txt
#   modified: file03.txt
#   modified: file04.txt
#   modified: file05.txt

解决方案

There are a few ways, but the simplest is probably:

git commit file01.txt
git commit file02.txt
...

Any paths you list after the commit command will be committed regardless of whether they're staged to be committed. Alternatively, you can stage each one, and then commit:

git add file01.txt
git commit

git add file02.txt
git commit

...

这篇关于如何使用Git一次提交一个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆