Accepting changes from a remote Git repository
Previously I wrote about how to work on an external project using Git. I didn't show how the owner could accept your changes though.
Connect to the remote repository
Being a committer to the project you of course already have the repository cloned. If you don't, now might be a good time to do that.
The person that's asked you to review their changes should have provided you with the repository location, and probably a branch with the changes that they'd like you to look at. Add the remote repository to yours.
git remote add \
craigwebster http://barkingiguana.com/~craig/project_name.git
Double check just to make sure the repository is correct.
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 the information on those juicy looking branches
git fetch craigwebster
Review, critique, rinse, repeat
To look at the changes you'll want to check them out to a local branch. Ask Git to track the remote branch for you so that any changes the patcher makes can easily be pulled into this branch.
git co --track \
-b craigwebster-sprozzled-gromits-are-good \
craigwebster/dev/sprozzled-some-gromits
Do your stuff, run the test suite, look over the code, discuss it with your peers, whatever.
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 that you accept the changes wholesale - you'll have to cherry pick commits if you don't.
Ask for a wider review
In some cases it may be appropriate to ask for a wider review of the changes before they are accepted into the master branch. Maybe the change is too huge to be in a minor release, or maybe it's patching a development branch. In these cases you can apply the changes to a 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, commit, or otherwise screw around with the commit much as you would with any change you've made.
Accepting the changes without review
If the change is appropriate to merge directly into the master branch then you can do that 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
curl -LO http://barkingiguana.com/2008/11/21/accepting-changes-from-a-remote-git-repository.html.orig
curl -LO http://barkingiguana.com/2008/11/21/accepting-changes-from-a-remote-git-repository.html.orig.asc
gpg --verify accepting-changes-from-a-remote-git-repository.html.orig{.asc,}
If you'd like to have a conversation about this post, email craig@barkingiguana.com. I don't bite.