0

error: Your local changes to the following files would be overwritten by checkout: Gemfile.lock Please, commit your changes or stash them before you can switch branches.

Thing is I have already pushed my code and now am in master branch with nothing to track. How do I fix this?

I have read up on on other posts here, but unable to apply to my situation.

Community
  • 1
  • 1
RPV
  • 397
  • 1
  • 5
  • 16

2 Answers2

0

Looks like there are some unstashed changes in there and you tree is dirty.

What does git status show ?

If it shows some untracked files, just save them with git stash save <some_label> and then try to do git checkout master

CherryDT
  • 25,571
  • 5
  • 49
  • 74
Mayur Nagekar
  • 813
  • 5
  • 13
0

git status will show you your local branch status if you 100% sure you branch is synched with the remote one, you can try reset your branch git reset --hard origin/master

Pavel
  • 1,627
  • 15
  • 12
  • i have a bunch of untracked files, which i'd like to not track – RPV Apr 28 '16 at 10:08
  • when i try git stash, i get 'no local changes to save' – RPV Apr 28 '16 at 10:09
  • @Pavel they are, if the checkout would introduce a new file with the same name as one of your untracked ones. I assume somebody accidentally commited `Gemfile.lock` (possibly due to `git add .` or something). It should probably be removed from the repo and added to `.gitignore`. – CherryDT Apr 28 '16 at 10:13
  • Hm I assumed this file shouldn't be commited, but whether it should or not appears to depend on what you are doing in Ruby, see [this question](http://stackoverflow.com/questions/4151495/should-gemfile-lock-be-included-in-gitignore). But regardless, the file should either be commited or ignored, but not untracked. – CherryDT Apr 28 '16 at 10:15
  • well, first of all you're right, if someone added the exact file name to repo as your local one then yes it will conflict and yes, you must add this file to .gitignore to avoid those problems in the future. If I were you I'd save my untracked files elsewhere, run git clean -df and then reset git, after that I'd resolve the .gitignore and return back my untracked files – Pavel Apr 28 '16 at 10:17