【问题标题】:How to read this Git printout, having remote repository/local branch confusion如何阅读此 Git 打印输出,有远程存储库/本地分支混淆
【发布时间】:2019-09-20 06:32:21
【问题描述】:

我不确定这个 Git 打印输出告诉我关于我的本地分支/远程存储库跟踪的内容。我该如何阅读?

我有 2 个本地分支机构:

  • “master”跟踪到名为“origin”的远程存储库。
  • “melmaster”跟踪到名为“caelt”的远程存储库。

当我输入命令git remote show origin 时,我完全理解了打印输出。当我输入命令git remote show caelt 时,我不太明白它给我的信息。我把这些打印输出放在下面。

git remote show origin
* remote origin
  Fetch URL: https://github.com/.../UnityCSharpConceptExperiments.git
  Push  URL: https://github.com/.../UnityCSharpConceptExperiments.git
  HEAD branch: master
  Remote branch:
    master tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (fast-forwardable)

git remote show caelt
* remote caelt
  Fetch URL: https://github.com/CAELT/SimulationAnimation.git
  Push  URL: https://github.com/CAELT/SimulationAnimation.git
  HEAD branch: master
  Remote branches:
    master    new (next fetch will store in remotes/caelt)
    melmaster tracked
  Local branch configured for 'git pull':
    melmaster merges with remote melmaster
  Local refs configured for 'git push':
    master    pushes to master    (fast-forwardable)
    melmaster pushes to melmaster (up to date)

问题 1

是线条吗,

`Remote branches: 
master    new (next fetch will store in remotes/caelt)`

说“caelt”存储库中有一个名为“master”的远程分支?这与我的本地分支(称为“master”)有什么不同?

问题 2

为什么说下一次 fetch 将存储在 remotes/caelt 中? fetch 和 pull 不一样吗?在那种情况下,我不会从'remotes/caelt'中提取并存储在本地分支'melmaster'中吗?不存储在'remotes/caelt?'

问题 3

关于线条,

 Local refs configured for 'git push':
    master    pushes to master    (fast-forwardable)
    melmaster pushes to melmaster (up to date)

这是说我的本地分支 'master' 正在推送到存储库分支 'caelt'/master' 或存储库分支 'origin/master'?我希望本地分支 'master' 推送到 origin/master 中的存储库 'origin'。我不希望本地分支“master”推送到 caelt/master 中的存储库“caelt”(如果在 caelt 存储库中确实有一个名为 master 的分支)。我怎么知道这是指哪个大师?

问题 4

在每个打印输出中,是一行

HEAD branch: master

指的是我设置为 HEAD 的本地驱动器中的分支?或者是指远程仓库中已经设置为HEAD的远程仓库中的分支?

【问题讨论】:

    标签: git cmd git-branch git-remote


    【解决方案1】:

    问题 1。

    是的。

    远程分支始终与本地分支保持不同。默认情况下,远程分支位于名为 remotename/branchname 的本地存储库中。

    例如,如果远程“caelt”有一个分支“master”,它将作为分支“caelt/master”存储在您的本地存储库中。

    问题 2。

    git pull 只是git fetchgit merge 的组合。所以如果你拉,首先执行一个标准的git fetch。之后,如果您当前的本地分支是“master”并且分支 master 配置为具有上游“caelt/master”,则会执行 git merge caelt/master

    问题 3。

    只需执行git config -l | grep branch.master 并看看你得到了什么。

    【讨论】:

    • 谢谢。当我尝试执行git config -l | grep branch.master 时,我收到一条错误消息:“'grep' 不被识别为内部或外部命令、可运行程序或批处理文件。”
    • 我想你在 Windows 上。你不应该使用 DOS 命令行来执行 git 命令。每个 git 安装都带有一个叫做“git bash”的东西。它是一个小巧但非常方便的 Windows 版本的 unix 命令行。请使用它,它使许多事情变得更容易。相信我 - 我也在 Windows 上。
    猜你喜欢
    • 1970-01-01
    • 2022-11-09
    • 2014-06-20
    • 2013-09-24
    • 2012-07-06
    • 2010-12-04
    相关资源
    最近更新 更多