2

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.

techsjs2013
  • 2,607
  • 5
  • 20
  • 25

2 Answers2

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
  • should I use fetch or pull?? – techsjs2013 Feb 10 '13 at 22:16
  • 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.

Git for beginners: The definitive practical guide

Community
  • 1
  • 1
ogzd
  • 5,532
  • 2
  • 26
  • 27
  • you tell me pull others tell me fetch, which one – techsjs2013 Feb 10 '13 at 22:16
  • @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
  • `git pull --rebase` is always an option – ogzd Feb 11 '13 at 08:27