Git - 在 repo 中添加所有新文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12220588/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 14:29:56  来源:igfitidea点击:

Git - Add all new files in the repo

git

提问by Justin808

I'm trying to automate an update process. The process is basically:

我正在尝试自动化更新过程。该过程基本上是:

  1. Check out repo A
  2. Check out repo B
  3. Run a process in repo B that updates/creates a bunch of files
  4. Copy files into repo A
  5. Compile repo A and make sure it doesn't fail
  6. Commit changes into repo A and repo B
  7. Push changes to the remote server.
  1. 查看回购 A
  2. 查看回购 B
  3. 在 repo B 中运行一个更新/创建一堆文件的进程
  4. 将文件复制到仓库 A
  5. 编译 repo A 并确保它不会失败
  6. 将更改提交到 repo A 和 repo B
  7. 将更改推送到远程服务器。

Everything is working as expected except step 6. I can commit the changes, but how do I commit any new files? I tried git add .as I've read elsewhere but that doesn't catch all the new files in all the sub directories. Is there an easy way to do a "Add all new files"?

除了第 6 步之外,一切都按预期工作。我可以提交更改,但如何提交任何新文件?我尝试过,git add .因为我在其他地方读过,但这并没有捕获所有子目录中的所有新文件。有没有一种简单的方法来执行“添加所有新文件”?

回答by Adam Dymitruk

git add -A

will stage all modifications to the working tree. Add really means "include in the index" or "add changes to the index".

将暂存对工作树的所有修改。添加的真正意思是“包含在索引中”或“向索引添加更改”。

回答by hayk.mart

Take a look here. Perhaps you're interested in git add -uor git add -A.

看看这里。也许您对git add -u或感兴趣git add -A

回答by Angel Angel

You can use git add -AAs already mentioned or the long subcommand git add --all

您可以使用git add -A如前所述或长子命令git add --all

回答by DRD

I know I'm late to the party here, but you can also do git -a -m "commit message here". This takes care of adding files as well as committing them in one command. I use this command pretty heavily.

我知道我参加聚会迟到了,但你也可以git -a -m "commit message here"。这负责添加文件以及在一个命令中提交它们。我非常频繁地使用这个命令。