2017-03-02 49 views

回答

1

經過一段時間後合併請求在項目中打開,因爲其他人將其更改合併到其中,所以您試圖合併到的分支版本已過時是正常的。

Gitlab通過顯示您更新的分支版本位於遠程分支後面來幫助您。

落後並不會妨礙合併行爲,但在您合併的分支之上對您的提交進行rebase是一種常見做法。這將使你的合併請求更新,將你的提交按照時間順序放在那些已經在那個分支上的提交之後。這種方法使合併負責人的工作更容易,因爲提交者本身已經解決了可能發生的任何衝突。

做一個rebase你提出會是這樣的場景如下:

# Add a remote named `upstream` pointing to the original repository 
git remote add upstream https://gitlab.example.com/example/your_project.git 

# Fetch the latest commmits from `upstream` 
git fetch upstream 

# Checkout our branch-A 
git checkout branch-A 

# Rebase our branch on top of the `upstream/develop` branch 
git rebase upstream/develop 

# If needed fix any conflicts that may have appeared and then `git rebase --continue` 

# Push the changes to the branch of your merge request 
git push --force origin branch-A 

注:的--force是必要的,當你推,因爲你正在重寫分支的提交歷史。

+0

感謝您的全面回答。但是,我需要'git remote add upstream'來做什麼?如果所有的遠程分支都已經被獲取,那麼是不是也可以只做一個'git rebase develop'? –

+1

你可以合併而不是rebase。否則,你知道你做了什麼,我不會推薦rebasing –