.gitignore不会忽略目录 [英] .gitignore is not ignoring directories

查看:95
本文介绍了.gitignore不会忽略目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我认为github gui中存在一些奇怪的配置,导致此问题并阻止我成功从命令行或git-bash轻松使用git。

我最终只是卸载了github和git,然后重新安装了git for windows。我现在已经有一切从命令行运行(除了我从git-bash运行的ssh之外)。 github gui更简单也更可靠。



感谢mu没有花时间去试图解决这个问题。我没有最终使用他的答案,但如果我不需要重新安装git,那就是我需要做的。






我在本地机器上使用github gui。我只注意到我正在做的一个提交就是更新我最近更新的所有节点模块。我将.gitignore设置为忽略整个 node_modules / 目录。



我不确定要做什么对这个。包含在.gitignore中的所有文件类型都被忽略。这只是它似乎忽略的目录。



这是我的.gitignore文件:

  ################# 
## Sublime Text
############### ##

* .sublime-project
* .sublime-workspace

#################
##图片
#################

* .jpg
* .jpeg
* .png
* .gif
* .psd
* .ai

#################
## Windows碎片
#################

#Windows映像文件缓存
Thumbs.db
ehthumbs.db

#文件夹配置文件
Desktop.ini

#使用文件共享的回收站
$ RECYCLE.BIN /

#Mac crap
.DS_Store

#################
##目录
#################
$ b $ dev /
cms / core / config /
node_modules /
> node_modules /
而不是 node_module /



编辑

由于 node_modules 目录已作为存储库的一部分进行跟踪,所以 .gitignore 规则不适用于此目录。



您需要使用

从git中解压目录

$ g $ r $ git rm -r --cached node_modules
git commit -m删除node_modules

您可以运行 git-bash



之后的 .gitignore code> rule会忽略掉目录。



请注意,这会从您的目录中删除目录 node_modules 其他回购协议一旦你进行了更改。只有你提交提交的原始仓库仍然有 node_modules 文件夹。


What I did:

I think there were some weird configurations from the github gui that caused this issue and prevented me from being able to easily use git from command line or even git-bash.

I ended up just uninstalling github and git then reinstalling just git for windows. I now have everything running off the command line(except ssh which I run from git-bash). Much easier and more reliable that the github gui.

Thanks to mu 無 for taking the time to try to figure this out. I didn't end up using his answer, but if I hadn't needed to do a reinstall of git it would have been what I needed to do.


I am using the github gui on my local machine. I just noticed that a commit I was about to make was going to update all of my recently update node modules. I set up my .gitignore to ignore the entire node_modules/ directory.

I'm not sure what to do about this. All the file types I included in .gitignore were ignored. It's just the directories that it seems to ignore.

Here is my .gitignore file:

#################
## Sublime Text
#################

*.sublime-project
*.sublime-workspace

#################
## Images
#################

*.jpg
*.jpeg
*.png
*.gif
*.psd
*.ai

#################
## Windows detritus
#################

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Mac crap
.DS_Store

#################
## Directories
#################

dev/
cms/core/config/
node_modules/

解决方案

You have a spelling mistake in the ignore rule - You are ignoring node_modules/ instead of node_module/.

EDIT

Since the node_modules directory is already tracked as part of the repository, the .gitignore rule will not apply to it.

You need to untrack the directory from git using

git rm -r --cached node_modules
git commit -m "removing node_modules"

You can run the above 2 in git-bash.

After this, the .gitignore rule will ignore the directory away.

Note that this will remove the directory node_modules from your other repos once you pull the changes in. Only the original repo where you made that commit will still have the node_modules folder there.

这篇关于.gitignore不会忽略目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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