Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 898
Abhishek Ranjan Avatar asked Oct 20 '25 10:10

Abhishek Ranjan


1 Answers

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.

like image 139
VonC Avatar answered Oct 22 '25 00:10

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!