0

I created a new directory c:\Src, where I've cloned a repository. After cloning I get the following

$ git branch  
* Search

$ git branch -a  
* Search  
remotes/origin/master  
remotes/origin/prototype

If i then try

$ git checkout -b master origin/master  

it returns

error: You have local changes to '<some_file>'; cannot switch branches

pull gives the same error.

I have not made any changes, and I'm confused why it doesn't use the master branch as default?

koopajah
  • 23,792
  • 9
  • 78
  • 104
user374275
  • 163
  • 1
  • 6

1 Answers1

0

Firstly, you might want to checkout a tracking branch for master. You can use -t or -track instead of the -b (or if you have a recent version of git you can just use git checkout origin/master and it will automatically create a tracking branch).

As for your specific error, you should run git status to see if you have any local changes. If you do, you can then run git stash, do your checkout/pull and then git stash pop afterwards.

Chris Rasys
  • 1,295
  • 11
  • 18
  • nice answer, but i think `git stash apply` is safer for beginners, as they won't loose the stashed changes and don't have to mess with the reflog – asymmetric Jan 07 '11 at 21:33