简体   繁体   English

Git pull-在osx / linux上的行为各不相同

[英]Git pull --all behaving differently on osx / linux

I thought running git pull --all was pulling the contents of all remote branches to the local repository. 我以为运行git pull --all所有远程分支的内容都拉到本地存储库中。 Until this morning anyway, when I ran this on my MacBook: 无论如何直到今天早上,当我在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.

I don't understand that error, isn't the whole point of specifying --all not to have to specify a branch? 我不明白的错误,是不是指定的整点--all不是必须指定一个分支? What is even more upsetting, is that the same code seem to work just fine on my Linux box: 更令人沮丧的是,相同的代码似乎在我的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
 ...

I understand that it might be too optimistic to hope for the same program to behave in the same way on different OSs, but I would like to know if I am doing this correctly, or whether this is a version problem, or whether I misunderstood something? 我了解,希望同一程序在不同的操作系统上以相同的方式运行可能太乐观了,但是我想知道我是否正确执行了此操作,或者这是否是版本问题,或者是否误解了某些内容?

Sorry for my previous question, I think I figured out the answer. 对不起我的上一个问题,我想我已经找到答案了。 Apparently I didn't define the upstream for my local branch foo . 显然,我没有为本地分支foo定义上游。 Running the following made git pull --all run fine on osx: 运行以下命令进行git pull --all在osx上都可以正常运行:

git branch -u foo origin/foo

For reference, based on this answer , the following command is useful to check the current tracking state of your repo: 作为参考,基于此答案 ,以下命令可用于检查存储库的当前跟踪状态:

git remote show origin

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM