What are the common use cases for git fetch?
I am learning Git and helping some colleagues get back on their feet to speed up. So far, I haven't found a compelling reason to use git fetch
. It doesn't seem like much usefull compared to use git pull
or even git pull --rebase
reasonable.
I discussed this with a co-worker and he came up with some relatively narrow and contrived situations where git fetch
would be used independently in a workflow, but I'm still not very convinced (for example, updating branches that do not have an upstream source requiring updating local repos without conflicts before they occur).
Are there any good use cases for regular use git fetch
?
source to share
I use it all the time, especially when I want to update some aspects of my local repo view before the repo without touching my working copy:
- just to get the tags (say when someone added a release tag)
- to get a new remote branch that I haven't used before (perhaps to start tracking a feature branch created by someone else)
- just update
origin/master
without affectingmaster
As for why I might care about pull
touching my working copy, it's probably because:
- I have uncommitted changes in my current branch that I don't want to commit yet.
- ... and I don't want to store them just for this
- I like the current state of the HEAD or working tree (maybe I have an assembly running in the background and can't
pull
update the source files underneath)
source to share