简体   繁体   中英

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. Below are my steps that I followed in order to push my code to my repository:

  1. Created .gitignore file with following content:

     .idea/* log/* tmp/*
  2. Pushed .gitignore file to repository:

     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:

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

But wherever I do git status it shows:

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

even if the vendor folder is in .gitignore file.

.gitignore only causes new, untracked files to be ignored. If a file was already added to the repository, like files in the vendor directory in this case, they will still be tracked.

You will have to remove the vendor files from the repository as well as adding them to .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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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