Saturday, February 19, 2011

Git recommended workflow

I have been using git for several months in a project developed only by myself. I have a local repository and push it regularly to github for backup purposes.

I want to add another developer to this project, however I will have the responsibility of integrating the whole project.

What is the recommended workflow?

Do we need a private and a public repository for each developer?

If the github repository is the main one, does the other developer have to clone this repository or the repository in my computer?

Should he have the right to push in my repository or should I pull from his repository?

From stackoverflow
  • Git is geared towards pulling, rather than pushing. Ideally, the other developer would clone from your public repo on Github; then, when he was done with his changes, you'd either pull from a repo that he makes available to you, or you'd integrate his changes with patches that he emails to you. Either way, you'd pull the changes into the private repo on your computer, fix any mistakes that result from the merge, and then push his changes to your public repo (the one on Github).

    Of course, there's nothing wrong with giving him commit access to your Github repo, either.

  • He can make his own fork of your github repository, and when he feels he is ready to integrate, he can send you pull requests (where you have his repos public URL as a remote) or he can send you git format-patch sets.

    Typically on this kind of work flow, the onus is largely on him to make sure that his patches applies cleanly to your public master.

  • A word of advice... make sure you're both clear on which git operations will rewrite history. Resetting branch pointers, rebasing, appending commits, etc. will rewrite the history which is okay but only for private branches. For branches that you are sharing (pushing to or pulling from) you should avoid rewriting history.

    Here's an article on Packaging software using Git that's a nice read. It's aimed at people doing large scale integration (like building linux distributions) but the principals are generally applicable.

0 comments:

Post a Comment