views:

6028

answers:

1

I'm thinking of asking my students to use git for pair programming. Because student work has to be secret, a public repo is out of the question. Instead, each student will have a private repo they maintain themselves, and they will need to exchange patches using git-format-patch. I've read the man page but I'm a little unclear which patches will be sent. The obvious thing for the students would be send all patches since the last send or (if git doesn't mind receiving the same patches redundantly) send all patches since the dawn of time. (Remember these are student projects, they last for a couple of weeks and are small, and performance is not a criterion.) Our best friend is simplicity and we are fond of brute force as well.

Can anyone give me a short series of examples that show two people, each with a private git repo, exchanging patches using git-format-patch and git-am? Or alternatively point me to existing git documentation and/or tutorial?

+12  A: 

It works best if they can see each other's git repos. git itself is managed this way (there's a public repo people can reference, and then they format-patch from there). If people never see each other's repos, things are a bit more difficult...

One thing they may do is maintain a reference to the last time they did a format patch. Let's say they start by just sending their entire tree (including .git):

tar cvf - mytree | gzip -9vc > /tmp/mytree.tgz
# mail /tmp/mytree.tgz
git tag last-send
# hack, commit, hack, commit
git format-patch -M -C last-send..
# mail 00* && rm 00*
git tag -f last-send

git tag in this form creates a "lightweight tag. It's a sort of bookmark. This will be an easy way for people to keep track of what they sent so they can send it again next time.

On the other side:

# get patches from mail and place in /tmp
git am /tmp/00*
rm /tmp/00*
Dustin
sadly, they never see each other's repos---although they may be both in front of a coputer working on one of the two repos. But this looks like what I was hoping for so it gets my up vite.
Norman Ramsey
Thanks for this answer. It helped me in converting a messy SVN repository into Git. My experiences are at http://blog.orfjackal.net/2009/05/converting-confused-svn-repositories-to.html
Esko Luontola