git add multiple files at once

笑着哭i 提交于 2019-11-28 18:56:36

问题


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?


回答1:


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




回答2:


How to add multiple files with different extensions to git all at one time...

You can add to git by explicitly listing each file with spaces as delimiters.

$ 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 different extensions. Posting here in case you miss this similar answer to a similar question.

Don't forget about interactive staging

Git interactive staging can also work wonders. To enter interactive staging (aka: adding, removing files):

 $ git add -i



回答3:


Maybe you have ignored your .o file, check out your .gitignore file if it exists.
Otherwise, you can add all files just by:

$ 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. :)



来源:https://stackoverflow.com/questions/8412081/git-add-multiple-files-at-once

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!