Why does "git pull" get all branches from repository but "git pull origin master" not do so?
The latter command, git pull origin master
, tells git to fetch and merge specifically the master
branch (from the remote named origin
, to be even more precise).
git pull
fetches updates for all local branches, which track remote branches, and then merges the current branch.
From the documentation of git pull
:
git pull
runsgit fetch
with the given parameters and calls git merge to merge the retrieved branch heads into the current branch
When you call git fetch
without arguments, the following happens
Fetches named heads or tags from one or more other repositories, along with the objects necessary to complete them.
git fetch
[fetches] from (...) a single named repository (...)
When you add arguments, only the specified remote and head (=branch/tag/commit/...) are fetched, and then merged.