I am new to git and I would like to know if I have to do a "git fetch" everytime my netbook gets on a network so I have the most updated version of the code from the repository.
Asked
Active
Viewed 75 times
2
-
Yes. This is a bad question. It is broad in the sense that it would require a complete explanation of DVCS systems. – pmr Feb 10 '13 at 22:01
-
1"In its default mode, `git pull` is shorthand for `git fetch` followed by `git merge FETCH_HEAD`." http://www.kernel.org/pub/software/scm/git/docs/git-pull.html – Christoffer Hammarström Feb 10 '13 at 22:36
-
Consider just using "git remote update". – Thorbjørn Ravn Andersen Feb 11 '13 at 09:28
-
For which purpose did you clone the repository? Are you contributing or just tracking? – Henk Langeveld Feb 13 '13 at 22:53
2 Answers
0
Yes, in the sense that git
will not grab changes from the remote repository unless you explicitly tell it to. No, in the sense that you don't have to grab those changes if you don't want to; you can run git fetch
and merge any changes it finds at your leisure.

chepner
- 497,756
- 71
- 530
- 681
-
-
This is a little oversimplified, but `git fetch` will get changes from the remote repository, but you have to merge them into your local branch manually with `git merge`. `git pull` combines the `fetch` and `merge` into one step. – chepner Feb 10 '13 at 22:50
0
You don't have to, that's why it is DVCS. But if you want to get the most updated version, yes you should pull
it from remote.
-
-
@techsjs2013 it depends on how you want your revision graph to look. `git pull` will fetch merge the upstream into your current branch. That means you may have a merge commit if you introduced something locally, but hadn't pushed it for others to see yet. If you prefer a more linear history, folks will often do a fetch, and then rebase against the upstream: `git rebase @{u}`. `git pull` has on option you can set to rebase by default. Folks advocating the fetch and rebase approach are interested in avoiding useless commits that pull can create. – John Szakmeister Feb 10 '13 at 22:36
-