问题描述
我创建了一个新的目录c:\Src,我已经克隆了一个存储库。克隆后,我得到以下内容:
pre $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ -a
*搜索
遥控器/原点/主控制器
遥控器/原点/原型
如果我然后尝试
$ git checkout -b master master origin / master
返回
错误:您对< some_file>进行本地更改;无法切换分行
拉给出相同的错误。
我没有做任何改变,我很困惑,为什么它不使用master分支作为默认值?
-t 或 -track
来代替 -b $ c $ (或者如果你有最新版本的git,你可以使用
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 - 本地更改后无法拉或推的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!