Abhishek Ranjan
Abhishek Ranjan

Reputation: 497

Is it possible to cherry-pick a commit from another repository without cloning the entire repository?

I have very limited bandwidth,so I was wondering if it whether it would be possible to get a commit from another repository without actually cloning it. The two repositories have the same file structure but they do not share history at all. Both of them are independent of each other but I still want to cherry-pick a commit from one of them to other. Is this possible ?

Upvotes: 4

Views: 2805

Answers (2)

ElpieKay
ElpieKay

Reputation: 30888

You could just fetch the branch that has the commit from another git repo and then git cherry-pick it.

Upvotes: 0

VonC
VonC

Reputation: 1326746

Short answer: in theory possible, but not easy to do.

From "Retrieve specific commit from a remote Git repository", you would need:

  • git repo hosting server with:
    • git 2.5+
    • git config uploadpack.allowReachableSHA1InWant true (on the server side)
  • A shallow clone with single commit fetch (again, git 2.5+, client side)

That is: you would initialize an empty repo, add the url of the remote origin repo, and:

git fetch --depth=1 ../testrepo/.git <SHA1>

That would bring only one commit.

Upvotes: 4

Related Questions