git fetch
actually can create some new branches, locally, but not yours. For each new branch it creates a remote-tracking branch, an image of the remote state, with which you can't interact like with your local branches, the ones listed on git branch
.
If some new branches have been created on your remote since last time you fetched, git will get their new references, with all needed ancestry.
Example :
On your local repo
A---B---C---D <<< master, origin/master
On the remote "origin", where work has been done (a new branch, and master
has advanced)
A---B---C---D---G <<< master
\
\
E---F <<< new-feature
If you fetch at this point, you'll get a new reference new-feature
(which you can verify with git branch -r
), and origin/master
will be updated to point to G, but not master
, which will still be unchanged.
G <<< origin/master
/
/
A---B---C---D <<< master
\
\
E---F <<< origin/new-feature
And then it also allows you to inspect these new changes before deciding whether and how to integrate them to your local work.