I'd like to try git (hosted on github) for a new project, but I have a doubt on how it works. I am working with another guy, do we need to have two forks of the project and then merge them every time one of us makes a change to the code or is it possible to work in pair on a single origin?
views:
137answers:
4With git you would both end up with local copies of the repository. When you push to (or pull from) the github repository you would be forced to merge if the other person made changes to a file that you had also made changes to since the last push / pull. There is no need for you both to have your own fork.
It's possible to have as many additional committers (called collaborators in GitHub terms) on a single project as you want. However, the maximum number is dependent on the pricing plan. Note that public repositories can have an unlimited number of collaborators.
As for Git itself: anybody who has write access to a repository can push to it.
First off, let me state that I don't have much experience with git myself. That said, let me get to my answer.
The short answer would be: yes, in a way, that's how it'll be. But it doesn't have to be as much as a problem as you state it to be.
I assumed that you know SVN for some reason, but let me know if you don't, and I'll try to write things down from a different point of view.
The SVN way, the centralized way, is that there is one repository and everyone has a working copy. In the working copy one can make changes, and then the changes can be committed to the repository. If two people had been making changes to their working copies at the same time, you might need to merge the changes, but if this is not the case everything will be automatic.
Git is decentralized. This is accomplished by not just having a single repository, but each user having his or repository. Usually the repository is accompanied by a working copy (with the working copy simply being the normal files and the repository being housed in .git
. You make changes to your working copy and then commit them to your repository. Then if you decide that the changes should be visible to the public you can push the changes to your repository to the public repository.
(Note that the public repository is public only because you treat it as such git knows no different. If you are working on a single feature with your coworker Bob, you can push to bob's repository instead and only when the two of you are done push it to the public repository, or not at all, if it's just your private modification.)
Basically, with typical usage, there will be more problematic merging with git than with SVN. Luckily git's merging is also better, so you'll have to do less yourself (or so I have been told). However, there shouldn't be too much conflicts if you do not wait months before pushing something to the public repository. Better yet, if you are afraid of merging (there is little reason to be, but if you are) you can push right after every commit - in which case you won't be doing more merging than with SVN. You are giving up some of the flexibility of git, but a large part of that can again be subverted by using branches well (which automatically means using explicit merging, but in git, it's really no thing to be afraid of).
The short answer is no, as long as you're using a public repository. Head to the admin section for the repository, select the "Collaborators" pane, and add as many users as you would like to be able to commit to the repository. All users would then use the same address to clone from and push to.
Just remember to pull their changes before you push your own.