why git fetch origin master failed?

git, github

Solution

This isn't about working or not, but about where you're asking git store what it downloads. If you omit the target in a refpec, you're asking git to store it in FETCH_HEAD. Thus, `git fetch origin master` is really `git fetch origin master:FETCH_HEAD`, and you're not touching `origin/master` or any ref at all (as you can see from the output, `master -> FETCH_HEAD`).

When you run `git fetch origin master:tmp` you're asking it to download the master branch (this is yet another layer, guessing that you want to deal with branches) and store it in a local branch named `tmp`. You would also see this mapping in the output.

If you want to update the remote-tracking branches, simply call `git fetch origin`. Calling the two-argument version of `git-fetch` is rarely something you want to do.

Problem

Assume that my local repository is one commit behind the repository at github. Then I commit one commit at the local repository At this time A------>commit 1 Github/master A------>commit 2 local repository/master I do the following steps to push commit 2 to github: - git fetch origin master - git rebase origin/master - git push origin master But I got the following errors: If I try to replace step 1 with `git fetch origin`, it works well Then I tried `git fetch origin master:tmp`, a branch named tmp successfully created So, My question is why `git fetch origin master` sometimes works(in the case `git fetch origin master:tmp`), while sometimes not work in the case step 1?

Original source

Related problems