Does the git fetch
command copy down the entire remote repository to my machine, or just the upstream of my current branch?
Asked
Active
Viewed 95 times
3

Mashmagar
- 2,556
- 2
- 29
- 38
-
git fetch fetches branches commits from origin, whithout doing merges. If you want to make a copy of a repo, use git clone. See answers on this question for further insights http://stackoverflow.com/questions/292357/whats-the-difference-between-git-pull-and-git-fetch – BigMike Apr 03 '13 at 14:08
-
1Entire repository may not be the best description. Fetch will get all of the commits in all of the branches since your last fetch/clone. Any history you already have won't be copied down again. – Roman Apr 03 '13 at 14:30
2 Answers
3
Yes, by default it fetches all 'named heads or tags' for the <repository>
specified.

GoZoner
- 67,920
- 20
- 95
- 145
-
-
1
-
I think my confusion comes from using `git push` and `git pull`. Don't they only operate on the current branch? – Mashmagar Apr 03 '13 at 14:39
-
1Yes, they only operate on the current branch. `git pull` is doing a fetch followed by a merge - which changes the working directory. – GoZoner Apr 03 '13 at 14:41
0
Depends on the options that you use. It can do both. It updates the repository with the data but doesn't merge the changes with your local. That would be with git pull
or git merge
. (git pull
per the documentation is a git fetch
followed by a git merge
)
https://www.kernel.org/pub/software/scm/git/docs/git-fetch.html

Schleis
- 41,516
- 7
- 68
- 87