简体   繁体   English

Git忽略供应商文件夹

[英]Git ignoring vendor folder

I have added vendor folder to my .gitignore file, but still whenever I do git status it shows me that vendor folder is modified.我已将供应商文件夹添加到我的.gitignore文件中,但每当我执行 git status 时,它仍显示供应商文件夹已被修改。 Below are my steps that I followed in order to push my code to my repository:以下是我为了将代码推送到存储库而遵循的步骤:

  1. Created .gitignore file with following content:创建了具有以下内容的.gitignore文件:

     .idea/* log/* tmp/*
  2. Pushed .gitignore file to repository:.gitignore文件推送到存储库:

     git add . git commit -m "test" git push origin master
  3. Created new project that contains vendor folder创建了包含供应商文件夹的新项目

  4. Pushed project with vendor folder to repository:将带有供应商文件夹的项目推送到存储库:

     git add . git commit -m "test" git push origin master
  5. Modified .gitignore file to ignore vendor folder:修改.gitignore文件以忽略供应商文件夹:

     .idea/* log/* tmp/* vendor/bundle/* vendor/cache/* vendor/plugins/*

But wherever I do git status it shows:但无论我做什么 git status 它都会显示:

modified:   vendor/bundle/ruby/1.9.1/bundler/gems/jquery-rails-f79e8f178

even if the vendor folder is in .gitignore file.即使供应商文件夹位于.gitignore文件中。

.gitignore only causes new, untracked files to be ignored. .gitignore只会导致新的、未跟踪的文件被忽略。 If a file was already added to the repository, like files in the vendor directory in this case, they will still be tracked.如果文件已添加到存储库中,例如在这种情况下vendor目录中的文件,它们仍将被跟踪。

You will have to remove the vendor files from the repository as well as adding them to .gitignore .您必须从存储库中删除供应商文件并将它们添加到.gitignore This can be accomplished with git rm --cached <file> , which will remove <file> from the repository, but will not delete it from your working copy.这可以通过git rm --cached <file>来完成,它将从存储库中删除<file> ,但不会从您的工作副本中删除它。

The next time you push to your remote, the files that you removed this way will be deleted from the remote.下次您推送到遥控器时,您以这种方式删除的文件将从遥控器中删除。

You are adding vendor directory wrong way.您以错误的方式添加供应商目录。 Try with below one.试试下面的一个。

/log/*.log
/tmp
/vendor

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM