【问题标题】:Rebase issue when use GIT Bash使用 GIT Bash 时的变基问题
【发布时间】:2017-06-23 02:49:47
【问题描述】:

当您在向 Gerrit 推送审查后使用解决冲突时,我遇到了问题。 这些是我的步骤:

# update from remote
$ git fetch

# get my change from gerrit
$ git fetch ssh://hoang.nth@localhost:29418/Git_training_class2 refs/changes/25/325/1 && git checkout FETCH_HEAD
# git rebase and problem
$ git rebase origin/master
You are not currently on a branch.
Please specify which branch you want to rebase against.
See git-rebase(1) for details.
    git rebase <branch>

D:\SVMC-Testing-Project>git branch
* (HEAD detached at FETCH_HEAD)
  master
D:\SVMC-Testing-Project>git --version
git version 2.9.3.windows.1

只在Git bash中发生过,但是当我使用linux环境时,还可以。

那么在这种情况下,我该如何解决window中的这个问题,因为我们的很多开发人员都在使用window。

最好的问候,

【问题讨论】:

  • 我不知道git rebase and problem 应该在做什么,但看起来您处于分离的 HEAD 状态,并且您不在分支上。正确地,Git 告诉你它不能做变基。要解决这个问题,只需签出你想要变基的分支。
  • 是的,我知道,但是当我在 linux 上使用时,它很好。
  • git rebase origin/master HEAD 怎么样? git rebase origin/master 在分离的 HEAD 上可以使用 git 版本 2.10.0.windows.1。
  • 我试过了,但似乎同样的问题:D:\SVMC-Testing-Project>git rebase origin/master HEAD 你目前不在一个分支上。请指定要针对哪个分支进行变基。有关详细信息,请参阅 git-rebase(1)。 git rebase

标签: git rebase


【解决方案1】:

Git 应该允许您对任何 HEAD 进行变基,即使是分离的...

看起来您可能遇到了错误。首先,尝试更新您的 git 版本(因为最新的是 2.13.1-2)。

解决方法是使用临时分支:

$ git fetch ssh://hoang.nth@localhost:29418/Git_training_class2 refs/changes/25/325/1
$ git checkout --force -b temp_branch FETCH_HEAD
  # now you are a branch 'temp_branch' so git shouldn't complain anymore
$ git rebase origin/master
  # should work

【讨论】:

  • 尊敬的 Zigarn 先生,我尝试将版本更新到 2.13,并按照您说的做了,然后 git 要求我将 temp_branch 设置为上游。 :( $git --version git version 2.13.1.windows.2 $git branch master * temp_branch $git rebase origin/master 当前分支没有跟踪信息。请指定你想要rebase的分支。见git -rebase(1) 获取详细信息。 git rebase 如果你想为这个分支设置跟踪信息,你可以这样做:
  • 好的。 'git branch -avv' 的结果是什么?还有'git remote -avv'?
  • 看起来,出于某种原因,您没有“origin/master”分支。
【解决方案2】:

我尝试将版本更新到 2.13,并按照你说的做了,然后 git 要求我将 temp_branch 设置为上游。 :(

$git --version
git version 2.13.1.windows.2

$git branch
  master
* temp_branch

$git rebase origin/master
There is no tracking information for the current branch.
Please specify which branch you want to rebase against.
See git-rebase(1) for details.

    git rebase <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> temp_branch

【讨论】:

    猜你喜欢
    • 2020-10-06
    • 2012-07-21
    • 2011-05-29
    • 1970-01-01
    • 2016-05-21
    • 2017-10-03
    • 2015-10-01
    • 2021-12-07
    • 2021-06-24
    相关资源
    最近更新 更多