git 无法一次性 add / commit 大量文件?

2016 年 4 月 24 日
 lua

OS X 系统,使用 git 一次性导入大量文件,文件列表参数由程序自动生成, n 大于 4096 :

git add -- <file1> <file2> ... <filen>

运行命令出现错误:

too many arguments (6861) -- limit is 4096

git 高手们有遇到这种情况吗,该怎么解决?

17694 次点击
所在节点    git
54 条回复
owlsec
2016 年 4 月 24 日
.gitignore
xiamx
2016 年 4 月 24 日
echo "<file1> <file2> <filen>" | xargs git add --
327beckham
2016 年 4 月 24 日
你既然能整理出<file1> <file2> <file3> 。。。。这么长的列表,那就再弄一个 bash 脚本,内容是:
git add <file1>
git add <file2>
git add <file3>
......
lua
2016 年 4 月 24 日
@Bardon @owlsec .gitignore 值得一试,简单粗暴直截了当
mengzhuo
2016 年 4 月 24 日
shell 的问题怎么能怪 git 呢
楼主的结构有问题了吧
sunjourney
2016 年 4 月 24 日
这么多文件真的是项目文件吗?什么东西的源码会这样?编译后的东西不要同步了好吧?
Clarencep
2016 年 4 月 24 日
如果不想提交的文件比较少,可以先 `git add .` 然后使用 `git reset HEAD 不想提交的文件` 来排除
Ixizi
2016 年 4 月 24 日
把要改的随便加点注释之类的,然后 git add -u
Kirscheis
2016 年 4 月 24 日
这是 shell 的问题,和 git 没关系。 echo " " | xargs git add -- 就好了
wizardoz
2016 年 4 月 24 日
同觉得问题不存在,不想 commit 的文件不要 add 就行了,又要 add 又不想 commit 的理由是什么?
skydiver
2016 年 4 月 24 日
@mengzhuo 楼主的结构有问题, 23333
itfanr
2016 年 4 月 24 日
git add -A
kxxoling
2016 年 4 月 24 日
git add . ;git rm xxx --cached?
kxxoling
2016 年 4 月 24 日
没提交的话 git add .; git reset xxx 应该也行。话说这么多文件就不能用通配符?
xwartz
2016 年 4 月 24 日
git add --all
marcushbs
2016 年 4 月 24 日
function gc {
for f in `git status |grep modified|awk '{print $3}'`
do
git add $f
done
git commit -m "$1"
git push
}
billlee
2016 年 4 月 24 日
你需要 xargs
hzlzh
2016 年 4 月 24 日
之前做 temp.im 这个服务的时候尝试过 push 100w 个文件到 github 上,是分批进行的, github 有做限制。
via https://study.congcong.us/t/57477
后来换七牛 CDN 来存了
BOYPT
2016 年 4 月 24 日
命令行长度是内核限制来的。跟 git 无关
bicoff9527
2016 年 4 月 24 日
奇怪的想法,大概是对 git 不熟

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://study.congcong.us/t/273985

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX