簡體   English   中英

重置后將master分支推送到github存儲庫

[英]Pushing a master branch to github repository after reset

所以基本上無論出於什么原因,在將我的master分支與另一個分支合並並將master分支推送到github <<<<<<< HEAD ,無論出於什么原因,我的代碼都充滿了<<<<<<< HEAD ,即使在我之前編輯了很多commit的地方,我也做了是git reset --hard到上一次提交,現在我嘗試將master分支推送到github repo時修復了代碼

 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'my github repo'
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.

現在執行git pull只會給我填充<<<<<<HEAD的代碼<<<<<<HEAD 所以我尋找了一些解決方案,前幾個結果建議使用git push -f origin branch但是當我這樣做時,我得到了

error: src refspec branch does not match any.
error: failed to push some refs to my github repo

那伙計們,我現在該怎么辦?

git push github master
To git@github.com:Joey-project/project.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:Joey-project/project.git'

是經常發生的錯誤。

我已經讀過解決方案之一是使用以下命令的變體:

git fetch github; git merge github/master

我想建議您也看看Git非快進更新被拒絕合並遠程更改 ,它有很多附加信息。

我自己找到了

git push origin HEAD --force

絕招。

暫無
暫無

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

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