Previously I wrote about how to work on an external project using Git. What I didn't cover was the other side of the equation: how the project owner accepts those changes.
Connect to the remote repository
As a committer on the project, you'll already have the repository cloned. If you don't, now's a good time to sort that out.
The person requesting a review should have given you a repository URL and probably a branch name. Add their repository as a remote:
git remote add \
craigwebster http://barkingiguana.com/~craig/project_name.git
Double-check that it's pointing to the right place:
git remote show craigwebster
* remote craigwebster
URL: http://barkingiguana.com/~craig/project_name.git/
New remote branches (next fetch will store in remotes/craigwebster)
dev/sprozzled-some-gromits master
Grab those branches:
git fetch craigwebster
Review, critique, rinse, repeat
To look at the changes, check them out to a local branch. Ask Git to track the remote branch so that any future updates from the contributor can easily be pulled in:
git co --track \
-b craigwebster-sprozzled-gromits-are-good \
craigwebster/dev/sprozzled-some-gromits
Now do your thing -- run the test suite, read through the code, discuss it with your peers, whatever your review process looks like.
git whatchanged
commit b9e0f1b4ff4bc196513c9551f6c25f0ee40d991f
Author: Craig R Webster <craig@xeriom.net>
Date: Wed Nov 19 20:53:08 2008 +0000
# and so on
I'll assume you're accepting the changes wholesale here. If you only want some of them, you'll need to cherry-pick individual commits.
Ask for a wider review
Sometimes it makes sense to get more eyes on a change before merging it into master -- maybe the change is too big for a minor release, or maybe it targets a development branch. In those cases, merge into the appropriate branch:
git checkout dev/version-2-0-45
git merge craigwebster-sprozzled-some-gromits
git commit -m \
"The Gromits are well and truly Sprozzled." \
--author "Craig R Webster <craig@xeriom.net>"
git push origin \
dev/version-2-0-45:refs/heads/dev/version-2-0-45
From here you can merge, rebase, or otherwise work with the commit just as you would with any other change.
Accepting the changes directly
If the change is ready to go straight into the master branch, that works too:
git checkout master
git merge craigwebster-sprozzled-some-gromits
git commit -m \
"The Gromits are well and truly Sprozzled." \
--author "Craig R Webster <craig@xeriom.net>"
git push origin master