Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use git clone to set up the repo without downloading files?

To manage yarn workspaces I am copying the pertinent subfolders into temporary folders and push them into their respective git repositories

To setup these repositories I am using git clone, which downloads everything and sets up the origin and remote configuration (and then copy files)

Can I skip the downloading of the repo folders?

Would this work?

git clone --filter=blob:none --no-checkout <repo>

EDIT

The usual way would be (as said by @edd34 and @pallgeuer below) with git init and remote add origin, but with the git clone above is only one line

-> what are the differences? What is achieved with this approach? And if incorrect, is there any way to get the same (provided a remote already exists) with git clone?

like image 884
GWorking Avatar asked Dec 09 '25 17:12

GWorking


1 Answers

The command:

$ git clone --no-checkout <repo> $(pwd)

will correctly clone only the .git folder, and no files, in the current working directory.

This should be equivalent to the more standard workflow:

$ git init
$ git remote add origin <url>
$ git fetch origin

You end up with the .git folder in your working directory and don't perform the HEAD checkout.

like image 61
Paolo Avatar answered Dec 11 '25 13:12

Paolo



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!