虽然我不是Git专家,但我已经在几个不同的项目中使用它一段时间了。在每个项目中,我总是执行git clone [repository]
,然后可以始终执行git pull
,当然前提是我没有未完成的更改。
最近,我不得不回退到以前的一个分支,并使用git checkout 4f82a29
进行了回退。当我再次准备进行拉取时,我发现我必须将我的分支设置回主干。现在,我无法直接使用git pull
进行拉取,而是必须指定git pull origin master
,这很麻烦,并表明我不完全理解发生了什么。
为什么会发生这种情况,不允许我直接使用git pull
而必须要指定origin master?我该如何将其改回来?
更新:
-bash-3.1$ cat config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[branch "master"]
[remote "origin"]
url = git@github.com:user/project.git
fetch = refs/heads/*:refs/remotes/origin/*
更新2:明确一下,我知道我的原始方法可能是错误的,但我需要修复这个仓库,以便我可以再次简单地使用git pull
。目前,git pull
的结果是:
-bash-3.1$ git pull
You asked me to pull without telling me which branch you
want to merge with, and 'branch.master.merge' in
your configuration file does not tell me either. Please
name which branch you want to merge on the command line and
try again (e.g. 'git pull ').
See git-pull(1) for details on the refspec.
If you often merge with the same branch, you may want to
configure the following variables in your configuration
file:
branch.master.remote =
branch.master.merge =
remote..url =
remote..fetch =
See git-config(1) for details.
我可以告诉git pull
合并哪个分支,它可以正确工作,但在执行git checkout
之后,git pull
不像最初那样工作。