git git一次添加多个文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8412081/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git add multiple files at once
提问by user1051003
I had this project with a lot .c files in source directory,then I make the project, there is .o files inside of the project, I also want to push these files to repository,so instead of add each .o which is possible but...,how to add .o files easily?
我有这个项目,在源目录中有很多 .c 文件,然后我制作了项目,项目中有 .o 文件,我也想将这些文件推送到存储库,所以不是添加每个 .o 是可能的但是...,如何轻松添加 .o 文件?
回答by elbowlobstercowstand
How to add multiple files with different extensionsto git all at one time...
如何一次将具有不同扩展名的多个文件添加到 git...
You can add to git by explicitly listing each file with spaces as delimiters.
您可以通过显式列出每个带有空格作为分隔符的文件来添加到 git。
$ git add file-name-1.php file-name-2.js file-name-3.html …
The accepted answer is perfect for the OP's specific case. But I got here—via Google—needing to add multiple files with differentextensions. Posting here in case you miss this similar answerto a similar question.
接受的答案非常适合 OP 的特定情况。但我到了这里——通过谷歌——需要添加具有不同扩展名的多个文件。如果您错过了对类似问题的类似答案,请在此处发布。
Don't forget about interactive staging
不要忘记交互式登台
Git interactive stagingcan also work wonders. To enter interactive staging (aka: adding, removing files):
Git 交互式登台也可以创造奇迹。要进入交互式暂存(又名:添加、删除文件):
$ git add -i
回答by ?imon Tóth
Putting aside the fact, that this is just a terrible idea, you can add them as any other file:
撇开事实,这只是一个糟糕的主意,您可以将它们添加为任何其他文件:
git add *.o
git commit -m "Committing compiled files, which is bad"
Of course instead of git add *.o
you can use git add */*.o
or even find -name *.o | while read x; do git add $x; done
当然,而不是git add *.o
你可以使用git add */*.o
甚至find -name *.o | while read x; do git add $x; done
回答by Kjuly
Maybe you have ignored your .o
file, check out your .gitignore file if it exists.
Otherwise, you can add all files just by:
也许你忽略了你的.o
文件,检查你的 .gitignore 文件是否存在。
否则,您可以通过以下方式添加所有文件:
$ git add .
$ git commit -am "You message"
However, I dot think it's a good idea to trace the .o
files. It's binary file, you'll get these files whenever you do build. Ignore it is a good practice. :)
但是,我认为跟踪.o
文件是个好主意。它是二进制文件,每次构建时都会得到这些文件。忽略它是一个好习惯。:)