Git添加。确实添加了.gitignore中列出的文件 [英] Git add . does add files listed in .gitignore

查看:102
本文介绍了Git添加。确实添加了.gitignore中列出的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想停止跟踪已添加到 .gitignore 文件的Git中的某些文件。



我使用了 git rm --cached (并且还尝试了 git rm -r --cached。),但运行 git add。,a git commit --dry-run 告诉我我的gitignore中的文件是 。



.gitignore 档案的内容为:

  / source / backup / * 
/site/index.php
/site/userscript.user.js

p>

这个gitignore有什么问题?

很好,当唯一的行是 source / backup / * 。只要我添加第二行, source / backup / * 文件也会被提交。

解决方案

清除您的索引。

  git reset 

停止跟踪备份文件夹中的文件。

  git rm  - 缓存源/备份/ 

单独提交此更改。

  git commit -m从git中删除备份文件夹。 

正常继续。如果您的忽略文件设置正确,忽略的文件不应该意外滑入。我建议在它之前加一个斜杠(假设文件夹存在于你的仓库的根目录中)。

 #。gitignore 
/ source / backup /
/site/index.php

开启YouTube 。主混帐。 http://youtu.be/ZDR433b0HJY


I want to stop tracking certain files in Git that I've added to the .gitignore file.

I used git rm --cached (and also tried git rm -r --cached .) but after running git add ., a git commit --dry-run tells me the files in my gitignore are "to be committed".

The contents of the .gitignore file are:

/source/backup/*
/site/index.php
/site/userscript.user.js

What's wrong with this gitignore?

Things were working just fine when the only line was source/backup/*. As soon as I added the second line, the source/backup/* files are getting committed as well.

解决方案

Clear out your index.

git reset

Stop tracking files in your backup folder.

git rm --cached source/backup/

Commit this change by itself.

git commit -m "Removing backup folder from git."

Proceed normally. Ignored files should not accidentally slip in at this point provided your ignore file is setup properly. I'd recommend preceding it with a slash (assuming that folder exists in the root of your repository).

#.gitignore
/source/backup/
/site/index.php

Open up YouTube. Master git. http://youtu.be/ZDR433b0HJY

这篇关于Git添加。确实添加了.gitignore中列出的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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