git添加除忽略.gitignore文件中的所有文件外的所有内容 [英] git add all except ignoring files in .gitignore file

查看:693
本文介绍了git添加除忽略.gitignore文件中的所有文件外的所有内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将源代码控制添加到没有任何项目的项目中。问题是,有很多文件最初添加到git与一个 .gitignore 文件,但我不知道如何添加所有文件,而不包括匹配 .gitignore 文件。

  git add * 

以上命令不会添加任何文件,因为它检测到 .gitignore 忽略的文件。

  git add -f * 

上面的命令将添加所有文件,包括我希望忽略的文件。



那么,如何在添加所有文件的同时仍然遵守 .gitignore em> file?

解决方案

我想你的意思是 git add。 which将所有文件添加到未在 .gitignore 中指定的仓库中 - 您可以通过输入 git status
$中的通常表示这个目录和所有其他目录是递归的,所以如果你从你的repo底层开始,你应该添加所有的文件。



我通常的git流程是创建 .gitignore 文件并将项目文件添加到回购。在导入文件后输入 git status 来测试 .gitignore 文件 - 如果我看到的文件是I已添加(例如,只有.php或.html,NOT .mp3或.mov),那么您可以 git add。添加所有内容, git commit -minitial commit提交它们,你应该设置。


I am adding source control to a project that had none. The problem is that there are a lot of files to initially add to git with a .gitignore file, but I can't figure out how to add all files without including the files matching something in the .gitignore file.

git add *

The above command will not add any files because it detects files which are ignored by the .gitignore.

git add -f *

The above command will add all files including the files I wish to ignore.

So, how do I add all files while still adhering to the .gitignore file?

解决方案

I think you mean git add . which will add all of the files to the repo that AREN'T specified in the .gitignore - you can see these changes by typing git status

The . in bash usually means this directory and all other directories recursively, so if you do this from the bottom level of your repo, you should add all of the files.

My usual git flow is to create the .gitignore file and add the project files to the repo. I'll test the .gitignore file by typing git status after importing the files - if I see the files that I've added (for example only .php or .html, NOT .mp3 or .mov), then you can git add . to add all, and git commit -m "initial commit" to commit them and you should be set.

这篇关于git添加除忽略.gitignore文件中的所有文件外的所有内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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