前言
有時候我們可能會碰到如以下的情況
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
以下是我的處理方式。
說明
說明一下這是什麼意思,這表示雲端那邊還「不知道你 local 有了這條 branch」,
因此我們在做 push 的動作時,也需要「同時把這個新的 branch 推上去」,
才能讓「雲端」跟「本地」的 git 有一樣的版本控制。
解決方式
我們要做的事情其實也很簡單,git 已經很貼心地告訴我們該怎麼解決了,
就是把他給你的那行複製下來,直接執行即可。
以上面例子來說,我們就是複製:
git push --set-upstream origin master
把本地的 git branch 透過 –set-upstream 也推上至雲端,
即可解決雲端 branch 不同步的問題。
註:「git push –set-upstream」的指令,可以簡寫為「git push -u」,效果是一樣的。