git clone - 本地更改后无法拉或推 [英] Can't pull or push after git clone - local changes

查看:419
本文介绍了git clone - 本地更改后无法拉或推的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个新的目录c:\Src,我已经克隆了一个存储库。克隆后,我得到以下内容:

pre $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ -a
*搜索
遥控器/原点/主控制器
遥控器/原点/原型

如果我然后尝试

  $ git checkout -b master master origin / master 

返回

 错误:您对< some_file>进行本地更改;无法切换分行

拉给出相同的错误。



我没有做任何改变,我很困惑,为什么它不使用master分支作为默认值?

解决方案

<首先,您可能需要为主人结帐追踪分支。您可以使用 -t -track 来代替 -b git checkout origin / master ,它会自动创建一个跟踪分支)。



至于您的具体错误,您应该运行 git status 来查看是否有任何本地更改。如果你这样做,你可以运行 git stash ,做结账/拉动,然后 git stash pop


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.

这篇关于git clone - 本地更改后无法拉或推的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆