What's the difference between "git fetch <url>" and "git add remote upstream <url>" followed by "git fetch upstream"?
When you fetch with a URL, you also have to specify the <refspec>
you want to fetch, i.e. the branch or tag, otherwise it will just fetch the default HEAD
of the remote URL as FETCH_HEAD
, which is probably not what you want.
The syntax is an optional +
followed by <src>:<dst>
. If you omit <dst>
, FETCH_HEAD
will be used.
So for example:
git fetch https://github.com/someuser/someproject refs/heads/master:upstream/master
which will create the upstream/master
remote branch locally.
More advanced options are available.