您好,登錄后才能下訂單哦!
本篇內(nèi)容主要講解“使用git push時報錯怎么處理”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“使用git push時報錯怎么處理”吧!
[root@361way shell]# git pushwarning: push.default is unset; its implicit value is changing inGit 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 的默認行為,其意是如果你執(zhí)行 git push 但沒有指定分支,它將 push 所有你本地的分支到遠程倉庫中對應匹配的分支。而 Git 2.x 默認的是 simple,意味著執(zhí)行 git push 沒有指定分支時,只有當前分支會被 push 到你使用 git pull 獲取的代碼。鍵入如下命令:
[root@361way shell]# git config --global push.default matching
[root@361way shell]# git push -u origin masterTo 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 dohint: 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)又有報錯,根據(jù)報錯內(nèi)容,大致了解的情況是,本地和遠端的內(nèi)容可能不一致,建議git pull 一份,再push到romte 。由于平時有些修改會在阿里云服務器上修改過的懶得push到遠端同步,所以本地和遠端的不一致也是有可能的。即然不一致,以阿里云上保存的為準吧,強制同步下。
[root@361way shell]# git push -u origin master --force
強制同步,發(fā)現(xiàn)可以正常同步內(nèi)容到github上,而且后面再加文件進行同步,發(fā)現(xiàn)也未出現(xiàn)報錯了。
到此,相信大家對“使用git push時報錯怎么處理”有了更深的了解,不妨來實際操作一番吧!這里是億速云網(wǎng)站,更多相關內(nèi)容可以進入相關頻道進行查詢,關注我們,繼續(xù)學習!
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內(nèi)容。