Git 2.x 中git push時遇到 push.default 警告的解決方法

Git 2.x 中git push時遇到 push.default 警告的解決方法

0.0382016.02.18 20:23:34字數 389閱讀 12061html

最近在學習使用 git&GitHub,而後今天遇到了一個問題。在執行 git add 和 git commit 操做以後,再進行 git push 操做,出現了以下提示:git

$ 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

第一感受是 FxxK 。
而後來看看這一長串英文是在說什麼:學習

警告:push.default (默認push)未設置;在Git 2.0 中,push.default 的值從‘matching’改成‘simple’了。消除此警告並保留之前的習慣,輸入:this

git config --global push.default matching

消除此警告並採用新的設置值,輸入:spa

git config --global push.default simple

當 push.default 的值設置成 ‘matching’ ,git 將會推送全部本地已存在的同名分支到遠程倉庫
從 Git 2.0 開始,git 採用更加保守的值'simple',只會推送當前分支到相應的遠程倉庫,'git pull' 也將值更新當前分支。
……(後面就不譯了).net

已經說的很清楚了,Git 2.0 須要設置 push.default 的值,二者的區別上面也說了,因此我就採用新的保守值吧,輸入:code

git config --global push.default simple

然而接下來執行 git push 仍是不頂用,由於上面警告的是兩個問題,因而再次提示:orm

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

還沒學到後面,就簡單百度了一下,結果只是半懂,好像首次 push ,因此輸入如下命令便可:htm

git push -u origin master

以後再直接執行 git push 就能夠了。
</br>
參考文章:
Git 2.0 更改 push default 爲 'simple'
在 GitHub 上管理項目blog

 

4人點贊

 

計算機

相關文章
相關標籤/搜索