1

Let's say there is the project repository (on GitHub) and my fork (also on GitHub). My fork is identical except contains one revision to a single file (a bug fix) which hasn't (yet) been accepted by the project repository. I'm trying to provide installation instructions to a third party about how to download the latest version of the software, including my bug fix.

As far as I know, they'll have to do this:

git clone http://projectrepo
git remote add myrepo http://myrepo
git fetch myrepo
git cherry-pick a12345
git remote rm myrepo

(Assume I do not intend to maintain myrepo up to date - I would like my instructions to outlive my involvement with the project, which could end soon. Also assume that other changes could take place to this file, so simply downloading a copy of the whole file is not safe.)

A few suboptimalities with this:

  1. They need to transfer two whole Git repos
  2. It's three extra commands just to get one file.

Are there better solutions? Can you obtain a single revision a simpler way?

4
  • Use the git protocol, git://somerepo, it's much faster. git rarely if ever pulls objects you already have, it doesn't care where the objects came from.
    – jthill
    Apr 23, 2012 at 4:47
  • Why do they need to apply the patches themselves? can't you point them to your repo, which already includes your bug fix?
    – CharlesB
    Apr 23, 2012 at 6:50
  • @CharlesB: see the statement about not maintaining myrepo. Apr 23, 2012 at 7:47
  • @SteveBennett: OK, didn't understand at first read
    – CharlesB
    Apr 23, 2012 at 8:29

3 Answers 3

4

Anything wrong with just creating a patch file and telling them to apply it? You could even save it as a gist to avoid having to email it.

Create the patch:

git format-patch -1 a12345

Apply it:

git clone http://projectrepo
cd projectrepo
wget https://raw.github.com/gist/<patch-file>
git am -3 <patch-file>
1
  • 1
    Err, that's a perfectly cromulent solution. Thank you. Apr 23, 2012 at 5:51
2

Skip the remote add/remote rm:

git clone http://projectrepo
git fetch http://myrepo remote-branch-name
git cherry-pick a12345

If you know the commit is the HEAD of remote-branch-name, then you can do git cherry-pick FETCH_HEAD instead.

0

AFAICT there is no need to manually tell git to fetch both repos. You can just go

git clone http://myrepo
cd myrepo; git co <rev/branch> # maybe

And git/github takes care of all the details.

1
  • Yeah, but then they wouldn't get the benefit of future improvements to the main project repo. Apr 23, 2012 at 4:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.