Is there a way to fork a file from a foreign Git repository without cloning the whole repository?
The closest you could get to doing this is by using sparse checkout, which means using Git 1.7+ and you still need to clone the repo (or use clone
's --depth
option to do a shallow clone). Borrowing largely from this answer, you could do the following:
git clone --no-checkout <URL to git repo> myrepo
cd myrepo
git config core.sparseCheckout true
vim .git/info/sparse-checkout # Add files you want checked out
git checkout <branch you want>
If you have Git version 1.7.7-rc0 or later, you can set configuration options with the clone
command:
git clone --config core.sparseCheckout=true --no-checkout <URL to git repo> myrepo
Also, see the following:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With