简体   繁体   English

在git log或gitk中看不到上游分支

[英]Cannot see upstream branches in git log or gitk

I forked a GitHub repo, cloned my fork locally and add the remote "upstream" to point to the original repo. 我分叉了一个GitHub存储库,在本地克隆了fork,并添加了远程“上游”以指向原始存储库。 It appears everything is set up correctly, but "git log" and gitk only show branches from origin (my fork) and not upstream. 看来一切都已正确设置,但“ git log”和gitk仅显示来自原点(我的叉子)的分支,而不显示上游的分支。

I have another machine on which everything works fine. 我有一台机器,一切正常。 The setup appears the same on both machines. 两台计算机上的设置看起来相同。 What am I missing? 我想念什么?

My steps: 我的步骤:

git clone https://github.com:johnpankowicz/govmeeting.git
cd govmeeting
git remote add upstream https://github.com/govmeeting/govmeeting.git
git branch --set-upstream master upstream/master
git fetch upstream

If I run "git log --oneline --decorate=short", I only see the origin branches. 如果我运行“ git log --oneline --decorate = short”,则只会看到原始分支。 For example: 例如:

dd98b4a (origin/master, master) Minor fixes in register. Documentation and minor UI changes. (#35)

But on my other machine, where it works, I also see the upstream branches: 但是在另一台可以运行的机器上,我也看到了上游分支:

dd98b4a (upstream/master, origin/master, master) Minor fixes in register. Documentation and minor UI changes. (#35)

Everything appears to be set up the same on both machines. 两台计算机上的所有设置似乎都相同。 The output is identical for each of the following commands: 以下每个命令的输出都相同:

$ git remote -v $ git remote -v

origin  https://github.com/johnpankowicz/govmeeting.git (fetch)
origin  https://github.com/johnpankowicz/govmeeting.git (push)
upstream        https://github.com/govmeeting/govmeeting.git (fetch)
upstream        https://github.com/govmeeting/govmeeting.git (push)

$ git remote show upstream $ git远程显示上游

* remote upstream
Fetch URL: https://github.com/govmeeting/govmeeting.git
Push  URL: https://github.com/govmeeting/govmeeting.git
HEAD branch: master
Remote branch:
  master tracked
Local ref configured for 'git push':
  master pushes to master (local out of date)

$ git branch -r $ git branch -r

origin/fix-webapp-startup
origin/master
origin/pass-ang-arg
origin/video
upstream/master

$ git ls-remote upstream $ git ls-remote上游

867818be9d597ced7be5e8c1f40e033cb7f65b01        HEAD
867818be9d597ced7be5e8c1f40e033cb7f65b01        refs/heads/master
f4521d466eb98903abba4ccd92b81c2511462a1d        refs/pull/15/head
6471492dfe3e253725e66265a30d8ef895d65630        refs/pull/22/head
... etc. ...

If upstream/master has been committed to, the relevant commit is no longer its HEAD, and won't be mentioned by git log. 如果上游/主服务器已被提交,则相关的提交将不再是其HEAD,并且不会在git log中提及。 The other machine hasn't received the new commit yet. 另一台计算机尚未收到新的提交。

Edit (More explanation): The --decorate looks through all the refs (all tags and tips of branches, both locally and on remotes) to see if any of them point to the commit. 编辑(更多说明):-- --decorate浏览所有ref (本地和远程上的所有ref (分支的所有标记和提示)),以查看它们是否指向提交。 So when a new commit appears, the commit is no longer the tip of the branch, and will no longer be mentioned by --decorate . 因此,当出现新的提交时,该提交不再是分支的尖端,并且不再由--decorate提及。 But --decorate does not actually query the remote repo for its refs, it only checks its local copy of it (all git repos contain complete local copies of its remotes). 但是--decorate实际上并不会在远程--decorate中查询其引用,它只会检查其本地副本(所有git repos都包含其远程服务器的完整本地副本)。 This local copy must be manually updated using eg git fetch . 必须使用例如git fetch手动更新此本地副本。 So on the other computer, the local copy of upstream was out of date. 因此,在另一台计算机上, upstream的本地副本已过期。

upstream/master on either of your machines is actually a local copy at the time of the most recent fetch of the master branch from the upstream remote. 在最近一次upstream远程获取 master分支时,任何一台计算机上的upstream/master服务器实际上都是本地副本。 It is not the actual branch on the remote. 不是遥控器上的实际分支。 It will only be updated whenever you run git fetch upstream master . 仅当您运行git fetch upstream master时,它才会更新。 This means that if anyone commits to master in the original GitHub repo, then the "other" machine will not reflect those changes but your most recent clone will. 这意味着,如果有人承诺master原始GitHub存储库中的内容,那么“其他”机器将不会反映这些更改,但您的最新克隆会反映出来。

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

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