日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學(xué)無先后,達(dá)者為師

網(wǎng)站首頁 編程語言 正文

解決辦法:error: failed to push some refs to 'https://github.com/xxxx.git'

作者:Logbook怪 更新時(shí)間: 2022-04-11 編程語言

在github遠(yuǎn)程創(chuàng)建倉庫后, 利用gitbash進(jìn)行提交本地文件的時(shí)候出現(xiàn)如下錯(cuò)誤:

[root@foundation38 demo]# git push -u origin master
Username for 'https://github.com': xuefeilong
Password for 'https://xuefeilong@github.com': 
To https://github.com/xuefeilong/test.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/xuefeilong/test.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

這里寫圖片描述
解決辦法:

1: 進(jìn)行push前先將遠(yuǎn)程倉庫pull到本地倉庫
$ git pull origin master    #git pull --rebase origin master
$ git push -u origin master

2: 強(qiáng)制push本地倉庫到遠(yuǎn)程 (這種情況不會(huì)進(jìn)行merge, 強(qiáng)制push后遠(yuǎn)程文件可能會(huì)丟失 不建議使用此方法)
$ git push -u origin master -f

3: 避開解決沖突, 將本地文件暫時(shí)提交到遠(yuǎn)程新建的分支中
$ git branch [name]
# 創(chuàng)建完branch后, 再進(jìn)行push
$ git push -u origin [name] 

我使用的是直接加入?yún)?shù)-f,但是不推薦比較粗暴:

[root@foundation38 demo]# git push -u origin master -f
Username for 'https://github.com': xuefeilong
Password for 'https://xuefeilong@github.com': 
Counting objects: 13, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (13/13), 975 bytes | 0 bytes/s, done.
Total 13 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), done.
To https://github.com/xuefeilong/test.git
 + 5c057df...abfded5 master -> master (forced update)
Branch master set up to track remote branch master from origin.

這里寫圖片描述

原文鏈接:https://blog.csdn.net/aaaaaab_/article/details/82315116

欄目分類
最近更新