3 ms·
Wow, after reading a dozen or so responses, I still don't really get it.
by pbreit 13y ago
Wow, after reading a dozen or so responses, I still don't really get it.
- lmm 13y agoI never liked stack overflow, so let me try here: because git is distributed, you actually have two "copies" of your code; one that's a mirror of what's on the server (origin/master), and one that's your local checkout (master). Things that in SVN you would just do by contacting the server (e.g. svn diff . https://server/repo/trunk https://server/repo/trunk) you instead do against your "local server copy" (git diff . origin/master). So there's an extra stage to think about; rather than making changes to your local checkout and committing them to the server, in git you make changes to your local checkout, commit them to your local repository, and then push them to the remote server. But this also works in the other direction: rather than fetching changes from the server directly into your local checkout, you fetch changes from the server to your local repository, then from there into your local checkout. At least, if you want to. "fetch" does the first of these, while "pull" does both of them together. Now, you can naturally ask why we would ever want this additional complexity, but as I said at the start it's the whole point of a DVCS. Conceptually, your repository on github and your local repository are the same kind of thing, rather than a client/server relationship. You can use git without using remotes at all, in which case you'd never use push, fetch or pull; in that mode it behaves rather like SVN (just with the repository being on the same machine as the checkout). Conversely, you can use it in truly distributed fashion, where there are several federated repositories, none of which is physically distinguished from the other. At that point there is no real notion of committing to the "canonical" repository, because there isn't one, but what you can do is commit to, and checkout from, your local repository, and you can synchronize your repository with another repository in either direction (i.e. you can send commits from your repository to another, or receive commits from another repository to yours). When using it in this fashion it becomes very important that these are different operations and you want to be able to manually control when each step happens.