【问题标题】:git does not show up a newly created branch Gerrit Code Review UIgit 不显示新创建的分支 G​​errit Code Review UI
【发布时间】:2013-07-09 18:38:22
【问题描述】:

通过 Gerrit Web UI,我从提交链中的一个旧提交创建了一个分支

本地存在以前版本的代码存储库。

我发出git pull 命令来更新我的本地仓库。

我尝试运行git branch -a,但这个新创建的分支没有出现。

但是,如果我将此 repo 克隆到其他地方,所有分支都会按需要显示。

任何人都可以对此有所了解吗?

更新:

我尝试按照this question 中的说明运行git ls-remote。这将显示新创建的头部。但是,git branch -a 不会显示存储库的更新状态。

【问题讨论】:

    标签: git gerrit


    【解决方案1】:

    git pull <remote> or git pull 命令只会更新你的本地仓库,但是当你运行git branch 命令时,从 Gerrit 创建的分支不会出现。您需要运行以下命令:

    $git check -b branch_name --track origin/branch_name
    

    其中branch_name 是在 Gerrit 中创建的分支名称。

    【讨论】:

      【解决方案2】:

      看起来像一个错误。确实是这样,但是您实际上可以执行git checkout new-branch,之后分支将在您执行git branch -a时出现

      这看起来有点奇怪,因为您看不到分支,但您可以签出分支。我假设您在看到git pull 时也看到了[new branch] test-branch -> origin->test-branch

      【讨论】:

      • 感谢您的回答...您是对的 我在git pull 上没有看到该消息[new branch]...
      【解决方案3】:

      我仍然不明白为什么会发生这种情况。 然而,一种方法是 clone 其他地方的仓库...这解决了我的问题。

      如果出于某种原因clone 不是您的选择不是,请删除远程引用并重新添加,如下所示:

      git remote -v
      
      #will display list of all...
      
      <remote name> <remote url/ or ssh alias(if configured)>
      <remote name> <remote url/ or ssh alias(if configured)>
      .....
      
      git remote rm <remote name>
      
      # add the same remote again
      git remote add <remote name> <remote url or ssh alias(if already configured)>
      
      # now pull 
      git pull <remote name>
      

      【讨论】:

        【解决方案4】:

        在其他人之前尝试使用这个命令,分支就会出现:

        git fetch origin <branch_name>
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2021-10-05
          • 2012-01-15
          • 1970-01-01
          • 2020-12-01
          • 2018-09-08
          • 2015-07-19
          • 1970-01-01
          • 2015-04-06
          相关资源
          最近更新 更多