问题:
$ git fetch
$ git merge
Now I get the error:
fatal: No commit specified and merge.defaultToUpstream not set.
解决办法:
Usually you do not invoke
git merge
without arguments (at least I don't know anyone who does). If you want thatmerge
defaults to the tracking branch, you need to setmerge.defaultToUpstream
to true:git config merge.defaultToUpstream true
. Yourmaster
branch has to trackorigin/master
in this case:git branch --set-upstream master origin/master
. This is done automagically iforigin/master
was already present when you cloned.Personally, I do
git fetch
and thengit merge origin/master
orgit pull
if I have no local commits.git merge后面需要跟参数,指明是跟的merge的哪个 branch,如git merge origin/master。