从 git 中删除 vendor/bundle 目录

Remove vendor/bundle directory from git

我已经为 ruby 使用 rbenv 一段时间了,我没有遇到文件被跟踪的问题;一切似乎都在它的地方,我真的没有遇到问题。

我最近为一个新项目切换到 rvm,并且不得不为我的环境更改一些东西。结果,每当我现在 运行 bundle,所有添加到我的项目中的 gem 都会通过 git 被跟踪,看起来像这样;

new file:   vendor/bundle/ruby/2.2.0/bin/aws-rb
new file:   vendor/bundle/ruby/2.2.0/bin/byebug
new file:   vendor/bundle/ruby/2.2.0/bin/erubis
new file:   vendor/bundle/ruby/2.2.0/bin/geocode
new file:   vendor/bundle/ruby/2.2.0/bin/nokogiri
new file:   vendor/bundle/ruby/2.2.0/bin/rackup
new file:   vendor/bundle/ruby/2.2.0/bin/rails
new file:   vendor/bundle/ruby/2.2.0/bin/rake
new file:   vendor/bundle/ruby/2.2.0/bin/rdoc
new file:   vendor/bundle/ruby/2.2.0/bin/ri
new file:   vendor/bundle/ruby/2.2.0/bin/sass
new file:   vendor/bundle/ruby/2.2.0/bin/sass-convert
new file:   vendor/bundle/ruby/2.2.0/bin/scss
new file:   vendor/bundle/ruby/2.2.0/bin/sdoc
new file:   vendor/bundle/ruby/2.2.0/bin/sdoc-merge
new file:   vendor/bundle/ruby/2.2.0/bin/spring
new file:   vendor/bundle/ruby/2.2.0/bin/sprockets
new file:   vendor/bundle/ruby/2.2.0/bin/thor
new file:   vendor/bundle/ruby/2.2.0/bin/tilt
new file:   vendor/bundle/ruby/2.2.0/bin/unicorn
new file:   vendor/bundle/ruby/2.2.0/bin/unicorn_rails
new file:   vendor/bundle/ruby/2.2.0/cache/actionmailer-4.2.6.gem
new file:   vendor/bundle/ruby/2.2.0/cache/actionpack-4.2.6.gem
new file:   vendor/bundle/ruby/2.2.0/cache/actionview-4.2.6.gem
new file:   vendor/bundle/ruby/2.2.0/cache/activejob-4.2.6.gem
new file:   vendor/bundle/ruby/2.2.0/cache/activemodel-4.2.6.gem
new file:   vendor/bundle/ruby/2.2.0/cache/activerecord-4.2.6.gem
new file:   vendor/bundle/ruby/2.2.0/cache/activesupport-4.2.6.gem

因此,github 不会显示我的全部提交,我的 git add 会永远显示,总体来说非常混乱。

使用 rbenv 我没有遇到这个问题,所以我只能假设这与我设置 rvm 的方式有关。这是我目前的 bash_profile

# Set architecture flags
export ARCHFLAGS="-arch x86_64"

# Ensure user-installed binaries take precedence
export PATH=/usr/local/bin:/usr/local/sbin:$PATH

# RBENV - add bin and shims to path
export PATH=$HOME/.rbenv/bin:$PATH
eval "$(rbenv init -)"

# Bash completion
if [ -f $(brew --prefix)/etc/bash_completion ]; then
    . $(brew --prefix)/etc/bash_completion
fi

# Git completion
if [ -f ~/.git-completion.bash ]; then
    source ~/.git-completion.bash
fi

# Aliases
alias b="bundle exec"
alias t="RAILS_ENV=test"
alias bi="bundle install; rbenv rehash"
alias bu="bundle update; rbenv rehash"

# message from RVM (5/2/16)
# first attempt below
#source /Users/username/.rvm/scripts/rvm
# next attempt below
source ~/.rvm/scripts/rvm

我相信当前的跟踪是由于我的路径是如何设置的,这是我目前不太了解的事情。

我想知道是否有人对此有一些经验,他们能否告诉我如何阻止我下载的所有 gem 被 git 跟踪。任何帮助将不胜感激:)

这是我的 .bundle/config 文件

---
BUNDLE_PATH: vendor/bundle
BUNDLE_DISABLE_SHARED_GEMS: true

这是 rvm env

的输出
export PATH="/Users/username/.rvm/gems/ruby-2.2.3/bin:/Users/username/.rvm/gems/ruby-2.2.3@global/bin:/Users/username/.rvm/rubies/ruby-2.2.3/bin:$PATH"
export GEM_HOME='/Users/username/.rvm/gems/ruby-2.2.3'
export GEM_PATH='/Users/username/.rvm/gems/ruby-2.2.3:/Users/username/.rvm/gems/ruby-2.2.3@global'
export MY_RUBY_HOME='/Users/username/.rvm/rubies/ruby-2.2.3'
export IRBRC='/Users/username/.rvm/rubies/ruby-2.2.3/.irbrc'
unset MAGLEV_HOME
unset RBXOPT
export RUBY_VERSION='ruby-2.2.3'

这是 which ruby

的输出

/Users/username/.rvm/rubies/ruby-2.2.3/bin/ruby

您应该添加一个 .gitignore 文件。

您必须删除。bundle/config(这是覆盖您的用户首选项的每个项目配置)。

确保您使用的是正确的 Ruby 版本($rvm list rubies 将显示当前路径中使用的当前 Ruby 版本)

如果您使用的是项目所需的 Ruby 版本,那么您应该已经为这个 Ruby 版本安装了捆绑器 gem,它应该可以工作。