使用 git pull 更新分支

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4843881/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 09:58:32  来源:igfitidea点击:

updating branches using git pull

git

提问by ant2009

git version 1.7.3.5

I have the following branches:

我有以下分支:

git branch
  image
  master
* video

I did some work at the office. And when I came home I always update on my home's notebook.

我在办公室做了一些工作。当我回到家时,我总是在家里的笔记本上更新。

However, when I did a git remote show originI get the following:

但是,当我执行 a 时,git remote show origin我得到以下信息:

  Local refs configured for 'git push':
    image   pushes to image  (up to date)
    master  pushes to master (fast-forwardable)
    video   pushes to video  (local out of date)

So I did a git pull for all of these branches:

所以我为所有这些分支做了一个 git pull:

git pull origin image
git pull origin master
git pull origin video

When I do a git status on the video and image branch I get:

当我在视频和图像分支上执行 git status 时,我得到:

 nothing to commit (working directory clean)

When I do a git status on the master branch I get:

当我在 master 分支上执行 git status 时,我得到:

Your branch is ahead of 'origin/master' by 5 commits.

Which I don't understand the following (fast-forwardable)and (local out of date)?

我不明白以下(fast-forwardable)(local out of date)

But in the git status for video it saids its up to date?

但是在视频的 git status 中,它说它是最新的吗?

Do I need to push my master if it is ahead by 5 commits?

如果我的主人领先 5 次提交,我是否需要推动它?

Many thanks for any suggestions

非常感谢您的任何建议

回答by Koraktor

git remote show origincompares your local repository with the remote:

git remote show origin将您的本地存储库与远程存储库进行比较:

  • fast-forwardablemeans you can push your local changes to the remote branch.
  • local out of datemeans your local branch is behind the remote branch and you should pull from it.
  • fast-forwardable意味着您可以将本地更改推送到远程分支。
  • local out of date意味着您的本地分支在远程分支后面,您应该从中拉出。

git statuscompares your local working directory with the current commit of the current branch (aka HEAD). Additionally it compares your local branch with the (local!) tracking copy of the remote branch (origin/master), hence the Your branch is ahead of 'origin/master' by 5 commits.

git status将您的本地工作目录与当前分支(又名HEAD)的当前提交进行比较。此外,它将您的本地分支与远程分支 ( origin/master)的(本地!)跟踪副本进行比较,因此Your branch is ahead of 'origin/master' by 5 commits.

To solve the divergence between git status(which shows only local data) and git remote show origin(which shows "live" remote data) you should run git remote update originwhich will update your local tracking branches. It will update your local origin/masterto the state of the remote's master. After that git statusshould give you something like Your branch is behind 'origin/master' by X commits, and can be fast-forwarded.

要解决git status(仅显示本地数据)和git remote show origin(显示“实时”远程数据)之间的差异,您应该运行git remote update origin这将更新您的本地跟踪分支。它会将您的本地更新origin/master为远程的master. 在那之后git status应该给你类似的东西 Your branch is behind 'origin/master' by X commits, and can be fast-forwarded.