2017-06-23 96 views
1

當您使用Gerrit推送審查後解決衝突時,我遇到問題。 這是我的步驟:使用GIT Bash時發生的Rebase問題

# update from remote 
$ git fetch 

# get my change from gerrit 
$ git fetch ssh://[email protected]: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環境,這是不錯。

所以在這種情況下,我該如何解決這個問題在窗口中,請注意我們的開發人員正在使用窗口很多。

最好的問候,

+2

我不知道是什麼混帳'變基和problem'是應該做的,但看起來你是在分離的頭狀態,你是不是一個分支。理所當然,Git是告訴你,它不能做一個rebase。要解決這個問題,只需簽出你想要分支的分支。 –

+0

是的,我知道,但是當我在linux上使用時,它很好。 –

+0

'git rebase origin/master-HEAD''' git rebase origin/master' on detached HEAD is okay with git version 2.10.0.windows.1. – ElpieKay

回答

0

的Git應該讓你變基的任何HEAD,甚至是超脫一個...

看起來你可能已經打了一個錯誤。首先,嘗試更新你的git版本(最新版本是2.13.1-2)。

一種解決方法是使用一個臨時黨支部:

$ git fetch ssh://[email protected]: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 
+0

尊敬的Zigarn先生, 我試着將版本更新到2.13,並且照你說的做了,然後git讓我將temp_branch設置爲上游。 :( $ git的--version Git版本2.13.1.windows.2 $ git的分支 主 * temp_branch $ git的變基原產/主 沒有爲當前分支沒有跟蹤信息。 請指定要變基對哪個分支 請查看git-底墊(1)瞭解詳細信息 git的變基 如果要設置這個分支跟蹤信息你可以這樣做:。 的Git分支--set -upstream-to = origin/ temp_branch –

+0

好的。 'git branch -avv'的結果是什麼?和'git remote -avv'? – zigarn

+0

由於某種原因,您看起來沒有「起源/主」分支。 – zigarn

0

我嘗試更新的版本2.13,和你說的一樣,然後混帳問我設置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