日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【已解决】github中git push origin master出错:error: failed to push some refs to(亲测)

發(fā)布時間:2024/9/20 编程问答 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【已解决】github中git push origin master出错:error: failed to push some refs to(亲测) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

【背景】

折騰:

【記錄】將googlecode上面的crifanLib遷移到Github上

期間出錯:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

Administrator@PC-20131018OHXV? /cygdrive/e/dev_root/git/crifanLib

$ git remote add origin https: //github .com /crifan/crifanLib .git

Administrator@PC-20131018OHXV? /cygdrive/e/dev_root/git/crifanLib

$ git remote - v

origin? https: //github .com /crifan/crifanLib .git (fetch)

origin? https: //github .com /crifan/crifanLib .git (push)

Administrator@PC-20131018OHXV? /cygdrive/e/dev_root/git/crifanLib

$ git push origin master

Username? for ?'https://github.com' :

Password? for ?'https://admin@crifan.com@github.com' :

To https: //github .com /crifan/crifanLib .git

? ! [rejected]??????? master -> master (non-fast-forward)

error: failed to push some refs to? 'https://github.com/crifan/crifanLib.git'

To prevent you from losing? history , non-fast-forward updates were rejected

Merge the remote changes (e.g.? 'git pull' ) before pushing again.? See the

'Note about fast-forwards' ?section of? 'git push --help' ?for ?details.

出錯了。

很明顯是:

本地沒有update到最新版本的項目(git上有README.md文件沒下載下來)

本地直接push所以會出錯。

【解決過程】

1.看到提示里面,感覺是本地的代碼不是最新的。

所以覺得應該是類似于svn中的,先update一下,再去commit,估計就可以了。

所以先去pull試試:

結果直接pull好像是不對的:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

Administrator@PC-20131018OHXV? /cygdrive/e/dev_root/git/crifanLib

$ git pull

warning: no common commits

remote: Counting objects: 6,? done .

remote: Total 6 (delta 0), reused 0 (delta 0)

Unpacking objects: 100% (6 /6 ),? done .

From https: //github .com /crifan/crifanLib

? * [new branch]????? master???? -> origin /master

You asked me to pull without telling me? which ?branch you

want to merge with, and? 'branch.master.merge' ?in

your configuration? file ?does not tell me, either. Please

specify? which ?branch you want to use on the? command ?line and

try again (e.g.? 'git pull ' ).

See git-pull(1)? for ?details.

If you often merge with the same branch, you may want to

use something like the following? in ?your configuration? file :

???? [branch? "master" ]

???? remote =

???? merge =

???? [remote? "" ]

???? url =

???? fetch =

See git-config(1)? for ?details.

看來需要先搞懂pull的用法。

2.估計是指定對應的要pull的目標即可。

所以再去試試pull origin:

?

1

2

3

4

5

Administrator@PC-20131018OHXV? /cygdrive/e/dev_root/git/crifanLib

$ git pull origin

You asked to pull from the remote? 'origin' , but did not specify

a branch. Because this is not the default configured remote

for ?your current branch, you must specify a branch on the? command ?line.

也還是不對。

有空再繼續(xù)搞懂原理后再弄。。

3.搜:

error: failed to push some refs to

參考:

github – git error: failed to push some refs to – Stack Overflow

去試試:

?

1

2

3

4

5

6

Administrator@PC-20131018OHXV? /cygdrive/e/dev_root/git/crifanLib

$ git pull --rebase origin master

From https: //github .com /crifan/crifanLib

? * branch??????????? master???? -> FETCH_HEAD

First, rewinding? head ?to replay your work on? top ?of it...

Applying: add? local ?crifanLib to github

可以看到,此時已經(jīng)把github上最新的文件下載下來了:

即,那個README.md文件。

4.接著再去:

git push origin master

?

1

2

3

4

5

6

7

8

9

10

11

Administrator@PC-20131018OHXV? /cygdrive/e/dev_root/git/crifanLib

$ git push origin master

Username? for ?'https://github.com' :

Password? for ?'https://crifancrifancrifan@github.com' :

Counting objects: 19,? done .

Delta compression using up to 4 threads.

Compressing objects: 100% (14 /14 ),? done .

Writing objects: 100% (18 /18 ), 112.33 KiB,? done .

Total 18 (delta 0), reused 0 (delta 0)

To https: //github .com /crifan/crifanLib .git

??? 6bae951..32d67c7? master -> master

即可成功把本地的文件都上傳到github上面去了。

5.此時再去github網(wǎng)站上也就可以看到對應文件了:

總結

以上是生活随笔為你收集整理的【已解决】github中git push origin master出错:error: failed to push some refs to(亲测)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內容還不錯,歡迎將生活随笔推薦給好友。