laravel .gitignore 不忽略文件夹
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39014896/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
.gitignore not ignoring folder
提问by Vertisan
I have a project in Laravel and I have forum in public directory which I don't want to push it to repository, so I write in .gitignore:
我在 Laravel 中有一个项目,我在公共目录中有论坛,我不想将它推送到存储库,所以我用 .gitignore 编写:
### Laravel ###
vendor/
node_modules/
# Laravel 5 & Lumen specific
bootstrap/cache/
.env.*.php
.env.php
.env
# SMF
public/forum/
# Rocketeer PHP task runner and deployment package. https://github.com/rocketeers/rocketeer
.rocketeer/
However, the entry still appears in Git status
Here is my tree with it:
+...
+ public
++ forum
+++...
+...
Where is the problem?
但是,该条目仍然出现在Git 状态
这是我的树:
+...
+ public
++ forum
+++...
+...
问题出在哪里?
回答by KmasterYC
In .gitignoreadd
在 。gitignore添加
public/forum
Run
跑
git rm --cached -r public/forum
回答by BartBog
The problem is that this folder is already in your index (you committed it at an earlier moment). Changes to files in the index will always be in "git status". Only new files in that folder will be ignored.
问题是这个文件夹已经在你的索引中了(你之前提交过)。对索引中文件的更改将始终处于“git 状态”。只会忽略该文件夹中的新文件。
To fix it. See my answer on https://stackoverflow.com/a/38304114/2274140
要解决这个问题。在https://stackoverflow.com/a/38304114/2274140上查看我的回答
回答by sarfaraz shaikh
Do the following to trigger the gitignore
:
执行以下操作以触发gitignore
:
Commit all your pending changes in the repository which you want to fix and push that.
Remove everything from the git index in order to refresh your git repository. This is safe. Use this command:
git rm -r --cached .
Add everything back into the repo, which can be done using this command:
git add .
Commit these changes, using this command:
git commit -m "Gitignore issue fixed"
提交您要修复的存储库中的所有未决更改并推送它。
从 git 索引中删除所有内容以刷新您的 git 存储库。这是安全的。使用这个命令:
git rm -r --cached .
将所有内容添加回 repo,这可以使用以下命令完成:
git add .
使用以下命令提交这些更改:
git commit -m "Gitignore issue fixed"