Question

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?

Était-ce utile?

La solution

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.

Autres conseils

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>

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top