Git只添加所有新文件,而不是修改文件 [英] Git add only all new files, not modified files

查看:1348
本文介绍了Git只添加所有新文件,而不是修改文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法只添加新文件而不用git添加修改过的文件?也就是说,这些文件被列为未跟踪的git状态。



除了单独添加每个文件外,



在我的情况下,这不是绝对必要的,对我来说真正的问题在这里得到解答:如何让git-diff和git log忽略新的和删除的文件?



是,不要在新文件上显示差异,所以我更多地询问这个问题,因为我无法在任何地方找到答案。 解决方案可能

也许

  git add $(git ls-files -o --exclude-standard)

git ls-files 让您列出由git管理的档案,通过一些选项进行过滤。 -o 在这种情况下过滤它只显示其他(即未跟踪的文件)



$(...)语句将该命令的返回值作为参数传递给 git add


Is there a way to only add new files and not add modified files with git? That is, files that are listed as untracked with git status.

Other than ofcourse adding each file separately.

It's not absolutely necessary to do this in my case, the real question for me is answered here: How to make git-diff and git log ignore new and deleted files?

That is, don't show diff on new files, so I'm asking this more because i couldn't find an answer to it anywhere.

解决方案

Maybe

git add $(git ls-files -o --exclude-standard)

git ls-files lets you list the files managed by git, filtered by some options. -o in this case filters it to only show "others (i.e. untracked files)"

The $(...) statement passes the return value of that command as an argument to git add.

这篇关于Git只添加所有新文件,而不是修改文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆