簡體   English   中英

git non-fast-forward被上游拒絕

[英]git non-fast-forward rejected with upstream

我有一個git repo,其中有一個上游設置的master,還有一個dev分支,該分支從該master獲取每個流。

我在我的dev分支上做了一些提交的更改,這些更改僅對特定分支有用,對master沒有幫助,我

我當前的分支是:

git status
On branch dev
Your branch is ahead of 'master' by 2 commits.

當我這樣做時,我的提交是可見的

git diff origin/master..HEAD

我的分支是最新的(並且像以前一樣通過master):

git pull
From .
 * branch            master     -> FETCH_HEAD
Already up-to-date.

但是,當我推動時,我就感到沮喪:

git push origin
To https://my_git.git
 ! [rejected]        dev -> dev (non-fast-forward)
error: failed to push some refs to 'https://my_git.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

任何提示都將不勝感激,我看了幾篇類似的文章: git push拒絕了非快進Git拒絕了非快進 ,但是在我看來,這些都不起作用。

謝謝

您的問題在這里:

git push origin 

您未指定要推送的任何分支。
假設您正在使用git <2.0,則必須設置要pull/push的分支。 在您的情況下,它嘗試推送所有分支,其中一個分支會生成錯誤。

這會為你

# get all latest changes from the remote
git fetch --all

# merge the changes to the local repository
git pull origin dev 

# push the changes to the remote
git push origin dev

Git v2.0發行說明

向后兼容性說明

當“ git push [$ there]”沒有說明要推送什么時,到目前為止,我們已經使用了傳統的“匹配”語義(只要您的分支已經發送到遠程,只要那里已經有同名的分支)即可。 。

在Git 2.0中,默認值現在是“簡單”語義,它推送:

  • 僅當當前分支設置為與該遠程分支集成時,才可以將當前分支轉移到具有相同名稱的分支; 要么

  • 如果要推送到通常不是從那里獲取的遠程站點,則僅將當前分支轉移到同名分支。

您可以使用配置變量“ push.default”進行更改。 例如,如果您想繼續使用“匹配”語義,可以將變量設置為“匹配”。 閱讀文檔以了解其他可能性。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM