Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gemfile.lock always has changes not staged for commit

I am running into this problem on a rails app I am working on. I was working on a feature branch and wanted to rebase from the most recent master. I ran the following commands:

$ git checkout master
$ git pull --rebase

If I try to checkout back to my feature branch I get the following error:

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

  modified:   Gemfile.lock

I have tried the following commands to resolve the Gemfile.lock back to aster with none of them being successful:

$ git checkout -- Gemfile.lock
$ git stash
$ git reset HEAD --hard

Every time I run a new git command I go back to the Gemfile.lock having changes not staged for commit.

Here are the following versions of libraries I am working with:

$ git --version => 2.3.3
$ bundler --version => 1.7.9
like image 450
tomciopp Avatar asked Mar 18 '15 18:03

tomciopp


People also ask

What is the Gemfile lock file?

The Gemfile.lock file is where Bundler records the exact versions that were installed. This way, when the same library/project is loaded on another machine, running bundle install will look at the Gemfile.lock and install the exact same versions, rather than just using the Gemfile and installing the most recent versions.

What does changes not staged for commit mean in Git?

There is now one additional commit in our repository which contains the change we made to README.md. The “changes not staged for commit” message shows when you run the “git status” command and have a file that has been changed but has not yet been added to the staging area.

Which operations are not included in the git commit execution?

When performing an operation including moving folders, files and even deleting several folders and files, there are operations which is actually doesn’t included into the staging area in the git commit execution as shown below : Below is the execution of the command : After committing the already changed files, push it to the Repository Git :

What is a commit in staging area in Git?

This means the staging area is somewhat of a triage space. If you realize an additional file needs to be added into a commit, you can add it to staging. Then, once you are sure you have added all the changes to the staging area, you can create a commit. To receive this message, we must first change a file in a Git repository.


1 Answers

There must be some process running in the background or some side-effect of executing the git commands in your shell that is modifying the Gemfile.lock.

I am not familiar with rvm's magic (although that sounds plausible); here are some other things to check:

  • In recent versions of Rails there is a "spring" background process that runs. Try running spring stop (or bin/spring stop or bundle exec spring stop) to gracefully terminate that process.
  • Likewise if you have any other Rails-related processes like rails server, guard, zeus, sidekiq, etc. running, try shutting those down.
  • You might be running a git pre-commit hook. Check the .git/hooks directory.
  • git might be an alias in your shell for another command. Run alias to see a list of shell aliases.
  • Your shell prompt might be executing code to do things like show the current git status and branch name in the prompt. This code would be executed after every shell command to redraw the prompt, and might have side-effects. Check your .bashrc or .bash_profile.
like image 63
Matt Brictson Avatar answered Nov 16 '22 02:11

Matt Brictson