Git pull - 在osx / linux上表现不同

时间:2016-01-20 10:25:27

标签: linux git macos

我认为运行git pull --all会将所有远程分支的内容拉到本地存储库。直到今天早上,当我在MacBook上运行时:

[me@macbox folder]> git --version
git version 1.9.3 (Apple Git-50)
[me@macbox folder]> git branch
* foo
  master
[me@macbox folder]> git remote -v
origin  git@gitserver:me/myrepo.git (fetch)
origin  git@gitserver:me/myrepo.git (push)
[me@macbox folder]> git pull --all
Fetching origin
You asked to pull from the remote '--all', but did not specify
a branch. Because this is not the default configured remote
for your current branch, you must specify a branch on the command line.
[me@macbox folder]> git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
[me@macbox folder]> git pull --all
Fetching origin
Already up-to-date.

我不明白这个错误,是不是指定--all不必指定分支的重点?更令人沮丧的是,相同的代码似乎在我的Linux机箱上运行得很好:

[me@linuxbox folder]> git --version
git version 1.7.1
[me@linuxbox folder]> git branch
* master
[me@linuxbox folder]> git remote -v
origin  git@gitserver:me/myrepo.git (fetch)
origin  git@gitserver:me/myrepo.git (push)
[me@linuxbox folder]> git pull --all
Fetching origin
remote: Counting objects: 164, done.
remote: Compressing objects: 100% (138/138), done.
remote: Total 164 (delta 114), reused 36 (delta 23)
Receiving objects: 100% (164/164), 33.63 KiB, done.
Resolving deltas: 100% (114/114), completed with 30 local objects.
From gitserver:me/myrepo
 * [new branch]      foo        -> origin/foo
   b4b1efe..4e5f299  master     -> origin/master
Updating 9fd42cb..4e5f299
Checking out files: 100% (15/15), done.
Fast-forward
 ...

我理解希望同一个程序在不同的操作系统上以相同的方式运行可能过于乐观,但我想知道我是否正确地执行此操作,或者这是否是版本问题,或者是否我误解了什么?

1 个答案:

答案 0 :(得分:1)

对不起我之前的问题,我想我找到了答案。显然我没有为我的本地分支foo定义上游。运行以下命令使git pull --all在osx上正常运行:

git branch -u foo origin/foo

作为参考,基于this answer,以下命令可用于检查回购的当前跟踪状态:

git remote show origin