简体   繁体   中英

Can't pull or push after git clone - local changes

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM