[英]git repository on selected files commit
I am having a problem in git repository on selected files commit. 我在选定文件提交的git存储库中遇到问题。
As in SCM or SVN if I have modified 4 files.But want to commit only two then I can easily commit the selected files only. 与SCM或SVN一样,如果我修改了4个文件,但是只想提交两个文件,那么我可以轻松地仅提交所选文件。
But in git when using cmd: git commit -a.It is going to commit all modified files. 但是在git中使用cmd时:git commit -a。它将提交所有修改过的文件。 If use cmd like git commit filename filename.It is not working.
如果使用像git commit filename filename这样的cmd,它将不起作用。
So any help how to commit only selected files in git. 因此,如何在git中仅提交选定文件的任何帮助。
Don't use git commit -a
if you don't want to commit everything - since -a
is "commit all". 如果您不想提交所有内容,请不要使用
git commit -a
因为-a
是“全部提交”。
Instead, use git add <filename>
to add the files you want to commit, and the just git commit
. 而是使用
git add <filename>
添加要提交的文件,然后添加git commit
。
For example, if you have three files foo
, bar
, and baz
, and you want to only commit the changes to foo
and bar
, then do: 例如,如果您有三个文件
foo
, bar
和baz
,并且只想将更改提交到foo
和bar
,那么请执行以下操作:
git add foo
git add bar
git commit
(You could also do git add foo bar
to add both files in a single command.) (您也可以执行
git add foo bar
以在单个命令中添加两个文件。)
Now it is working. 现在正在工作。
git commit ... <file> ...
When files are given on the command line, the command commits the contents of the named files, without recording the changes already staged.当在命令行上提供文件时,该命令将提交命名文件的内容,而不记录已进行的更改。 The contents of these files are also staged for the next commit on top of what have been staged before.
这些文件的内容也会在之前已执行的内容的基础上,为下一次提交而进行。
To commit only some (added!) files do this: 要仅提交一些(添加!)文件,请执行以下操作:
git commit sample_file1.txt sample2.php file3.cs
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.