Git 一次提交 500 个文件?

标签 git batch-file git-commit

我有数以千计的文件需要提交,但我在一次提交所有文件时遇到了问题。如何自动一次提交 500 个文件?前 500 个文件应该有提交消息“Initial commit part 1”,接下来的 500 个文件应该有“Initial commit part 2”,等等。如果重要的话,我正在使用 Windows。

最佳答案

我在 git 文档中没有看到任何关于添加一定数量文件的内容。如果可能的话,那就太好了。

您可以做的是将您的提交分成更小的提交,采用几种不同的方式,这可能比任意数字更有意义。

您可以提交具有特定扩展名的所有文件:

$ git add *.rb
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        new file:   a.rb
        new file:   b.rb
        new file:   y.rb
        new file:   z.rb

您可以按目录提交文件:

$ git add first_dir/

或者(最没有意义),您可以提交字母表前半部分的所有文件(随后是后半部分):

$ git add [a-j]*
$ git status                                                                                                                                               
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        new file:   a.rb
        new file:   b.rb

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        y.rb
        z.rb

有很多方法可以分解一个大的提交——我推荐的是对您的文件最合乎逻辑的方法。

关于Git 一次提交 500 个文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31437793/

相关文章:

git - Jenkins SCM 同步配置插件不工作

git - 我怎样才能第一次 pull 远程目录?

用于svn删除文件夹集的windows批处理脚本

batch-file - 使用 REG QUERY 仅返回注册表项的值

android - 更改名称后提交类(class)

git - github API 提交状态 "failure"和 "error"之间的差异?

git - 如何使用 PowerShell 脚本运行 Git 命令

混帐 : How to remove only empty directories(not un-tracked files) in a git repo

batch-file - 批处理文件在当前目录树中搜索目录

git - 从 Git 存储库中删除多个已从磁盘中删除的文件