Fetch
Running fetch will pull all refs and objects that we don't already have from the remote repo, and will put them into the object database.
- fetch is opposite of push, in the sense that fetch will import branches, while push will export them
- when we run
git push origin master
, we are exporting our master branch to origin. If we were to rungit branch
on origin, we would see our local branch that we just pushed, listed as a local branch.- ex. Imagine we had a repo called
foo
, then cloned in locally into a different directory on our machine and called itbar
. Onbar
, origin would default tofoo
(since it was copied fromfoo
).foo
would not have an origin by default, since it did not come into existence by being copied. We could manually addbar
as a remote. Now, if we made a branch onfoo
and pushed it, that branch would be available locally onbar
.
- ex. Imagine we had a repo called
- when we run