Search code examples
gitversion-controlmergegit-tower

Git won't let me switch branches as "changes to the following files would be overwritten", however, git-status shows no changes


OK, so I have the following branches:

git branch
  2012-08-06-AAH
  2012-08-06-JWH
  2012-08-06-Master
* master

I want to checkout to 2012-08-06-AAH. So I do this:

git checkout 2012-08-06-JWH
error: Your local changes to the following files would be overwritten by checkout:
    MyProject/canada/rocky_mountaineer/best/coast_to_coast_rail/index.html
    MyProject/europe/train_tours/scenic_europe/index.html
    MyProject/europe/train_tours/springtime_alps/index.html
    MyProject/europe/train_tours/week_in_spain/index.html
    MyProject/europe/train_tours/windmills_vineyards_paris/index.html
    MyProject/europe/train_tours/wonderful_france/index.html
    MyProject/europe/train_tours/wonders_st_petersburg_moscow/index.html
Please, commit your changes or stash them before you can switch branches.
Aborting

OK... Fair enough. So I do this:

git status
# On branch master
nothing to commit (working directory clean)

Um... So how do I 'commit your changes or stash them' if there is nothing to commit?

Thanks for your help - I am a bit of a Git newbie (mostly using Tower, the GUI client), and when that failed me, I resorted to command line.


Solution

  • If you are sure you didn't made any local modification to those files, you can try a

    git checkout -- .
    

    That would reset the working tree to HEAD, and should allows for the checkout to proceed.