最近在學(xué)習(xí)使用 git&GitHub,然后今天遇到了一個(gè)問(wèn)題。在執(zhí)行 git add 和 git commit 操作之后,再進(jìn)行 git push 操作,出現(xiàn)了如下提示:
$ git push
warning: push.default is unset; its implicit value has changed in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the traditional behavior, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.
Since Git 2.0, Git defaults to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.
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)
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
第一感覺(jué)是 FxxK 。
然后來(lái)看看這一長(zhǎng)串英文是在說(shuō)什么:
警告:push.default (默認(rèn)push)未設(shè)置;在Git 2.0 中,push.default 的值從‘matching’改為‘simple’了。消除此警告并保留以前的習(xí)慣,輸入:
git config --global push.default matching
消除此警告并采用新的設(shè)置值,輸入:
git config --global push.default simple
當(dāng) push.default 的值設(shè)置成 ‘matching’ ,git 將會(huì)推送所有本地已存在的同名分支到遠(yuǎn)程倉(cāng)庫(kù)
從 Git 2.0 開(kāi)始,git 采用更加保守的值'simple',只會(huì)推送當(dāng)前分支到相應(yīng)的遠(yuǎn)程倉(cāng)庫(kù),'git pull' 也將值更新當(dāng)前分支。
……(后面就不譯了)
已經(jīng)說(shuō)的很清楚了,Git 2.0 需要設(shè)置 push.default 的值,兩者的區(qū)別上面也說(shuō)了,所以我就采用新的保守值吧,輸入:
git config --global push.default simple
然而接下來(lái)執(zhí)行 git push 還是不頂用,因?yàn)樯厦婢娴氖莾蓚€(gè)問(wèn)題,于是再次提示:
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
還沒(méi)學(xué)到后面,就簡(jiǎn)單百度了一下,結(jié)果只是半懂,好像首次 push ,所以輸入以下命令即可:
git push -u origin master
之后再直接執(zhí)行 git push 就可以了。
</br>
參考文章:
Git 2.0 更改 push default 為 'simple'
在 GitHub 上管理項(xiàng)目