Reputation: 1573
I am a beginner to Git and Github and still confused about them. It is said that we can use Git without Github when collaborating with other people. However, it is also said that Git works locally on one's computer. If we do not use Github, how can we collaborate while Git works only locally?
Upvotes: 23
Views: 6464
Reputation: 60245
You collaborate by swapping commits around among repositories and cooperating to whatever extent you find convenient on what to name interesting ones. That's it. Really: that's all there is to it.
Github runs a server that speaks most of the main protocols git supports for swapping commits and refnames around, and it has a web GUI on top of a big helping of handy abstractions and features for browser-mediated access, but when it comes right down to it it's all about swapping commits. There's lots and lots of ways to do that, because the underlying structure is (quite literally incredibly) simple. It's so simple people don't believe it.
Your repos are yours; what goes on in them is your business alone. The idea is getting commits into another repository is in some agreed-on (for each repo) sense publishing them. What's in at least some (including your own) repos will include rough-draft commits and random notes, experiments and outright garbage that nobody wants. Nobody cares what's in your personal repos any more than they care what's in the notes on your desk, it's the ones you publish that matters.
Using multiple repos for a single-project workflow is common -- creating a sandbox clone for really experimental work quite literally doesn't take two seconds for even the largest repositories (any subsequent checkout might take some time). You start doing clones to a tmpfs with barely a thought.
And in every repo you have the full power of a world-class vcs available for your own exclusive and personal use.
Upvotes: 2
Reputation: 9062
Git is a version control software that sets repositories. How it's done and how you manage them is another story, but the main point is that code stays in repositories. All repositories are identical, since this is a distributed system. The problem is that when collaborating, the entire team needs access to the same repository.
This is basically what github does: it creates a repository that acts as a main repository, and every team member synchronizes his repository with the "main" one (remember that the repository from github is the same as yours).
Why not sync it to the repository on your pc? Because it's easier. You would have to set up a server, to give your ip address, you may create security issues and so on. But it could be done. Also, if you really want to protect your code from a company for example, just create a git repository on a machine and sync everybody's repositories to that one.
Upvotes: 2