新聞中心
git push 命用于從將本地的分支版本上傳到遠(yuǎn)程并合并,但是有些小伙伴在使用此命令時(shí)會(huì)遇到一些問(wèn)題,本篇文章為大家列舉了常見的兩個(gè)問(wèn)題,有需要的小伙伴可以參考一下。

錯(cuò)誤一:
[root@361way shell]# git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
放”狗”查詢后,得知‘matching’ 參數(shù)是 Git 1.x 的默認(rèn)行為,其意是如果你執(zhí)行 git push 但沒有指定分支,它將 push 所有你本地的分支到遠(yuǎn)程倉(cāng)庫(kù)中對(duì)應(yīng)匹配的分支。而 Git 2.x 默認(rèn)的是 simple,意味著執(zhí)行 git push 沒有指定分支時(shí),只有當(dāng)前分支會(huì)被 push 到你使用 git pull 獲取的代碼。鍵入如下命令:
[root@361way shell]# git config --global push.default matching
錯(cuò)誤二:
[root@361way shell]# git push -u origin master
To https://361way:mypassword@github.com/361way/shell.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://361way:mypassword@github.com/361way/shell.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first merge the remote changes (e.g.,
hint: 'git pull') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
再次push,發(fā)現(xiàn)又有報(bào)錯(cuò),根據(jù)報(bào)錯(cuò)內(nèi)容,大致了解的情況是,本地和遠(yuǎn)端的內(nèi)容可能不一致,建議git pull 一份,再push到romte 。由于平時(shí)有些修改會(huì)在阿里云服務(wù)器上修改過(guò)的懶得push到遠(yuǎn)端同步,所以本地和遠(yuǎn)端的不一致也是有可能的。即然不一致,以阿里云上保存的為準(zhǔn)吧,強(qiáng)制同步下。
[root@361way shell]# git push -u origin master --force
強(qiáng)制同步,發(fā)現(xiàn)可以正常同步內(nèi)容到github上,而且后面再加文件進(jìn)行同步,發(fā)現(xiàn)也未出現(xiàn)報(bào)錯(cuò)了。
文章名稱:使用gitpush時(shí)報(bào)錯(cuò)處理方案
文章起源:http://www.dlmjj.cn/article/dhjdcdi.html


咨詢
建站咨詢
