Git pull无法工作

18

我没有使用github,我们在机器上搭建了git。

我从主分支(master)创建了一个叫做experiment的新分支。但是当我尝试执行git pull时,我得到以下消息。

> git pull
You asked me to pull without telling me which branch you
want to merge with, and 'branch.experiment.merge' in
your configuration file does not tell me either.    Please
specify which branch you want to merge on the command line and
try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details.

这里是git remote show origin的结果

> git remote show origin
* remote origin
  Fetch URL: ssh://git.domain.com/var/git/app.git
  Push  URL: ssh://git.domain.com/var/git/app.git
  HEAD branch: master
  Remote branches:

    experiment      tracked
    master          tracked
  Local branches configured for 'git pull':
    master     merges with remote master
  Local refs configured for 'git push':
    experiment pushes to experiment (local out of date)
    master     pushes to master     (up to date)

我从上面的消息中了解到,experiment分支被映射到origin/experiment。我的本地仓库已经知道它已经过时了。那我为什么不能用git pull命令呢?

这是我创建该分支的方式:

git co -b experiment origin/experiment

3个回答

26

拉取:

git pull origin experiment

推送:

git push origin experiment

谢谢。有人知道我需要做什么,才能让git pull和git push单独完成工作吗? - Nick Vanderbilt
1
你可以创建GIT别名。例如,如果你只想使用那个实验分支,你可以编写一个命令pull e或类似的命令,它将执行相同的git pull origin experiment操作。在这里阅读有关别名的信息:http://git.wiki.kernel.org/index.php/Aliases - Stewie Griffin
但是为什么git pull对于某些分支有效而对于其他分支无效呢?通常,git pull会从远程拉取当前检出的分支,但在某些情况下它不起作用,你会得到OP所描述的错误信息。我不明白为什么会出现这种差异。 - geoidesic

2

查看此问题的答案以获取信息,并将示例中的"master"更改为"experiment"


0

我在我的Eclipse GitHub插件中遇到了这个问题。

这可能是由于您的存储库中存在一些冲突文件而导致的。您仍然在尝试检入文件。 因此,之后会检查您的本地存储库而不是主存储库。 因此,您无法在主(head)存储库中拉取或检入任何内容。

我有一个解决方案可能有用,它对我最多次有效。 只需按照以下步骤进行: 1)右键单击冲突文件 2)单击替换为 -> head revision 3)等待一段时间(保持耐心,需要时间) 4)对所有冲突文件重复所有先前的步骤


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接