Search code examples
ruby-on-railsgitruby-on-rails-4gitignoregemfile.lock

Git will not ignore Gemfile.lock


I have a Gemfile.lock that git simply will not ignore. It's in my gitignore file (see below) but it keeps showing under unstaged changes whenever I bundle install. Anyone else ever run into something like this? Thanks in advance.

My Gitignore looks like this:

/.tags*
/log
/tmp
/db/*.sqlite3
/public/system
/coverage/
/spec/tmp
**.orig
rerun.txt
Gemfile.lock
...

Solution

  • Is it because the Gemfile.lock is already committed to your repository? Is it showing as a new file (with ?? in git status) or a modification (with M in git status). If it's the latter then you will need to remove the file with git rm Gemfile.lock. Once you commit that change then the file should stop showing up in git status.

    As an aside, it's generally best practice to keep the Gemfile.lock committed to the repository (unless this is a gem). Here's a good SO question about that topic: Should Gemfile.lock be included in .gitignore?