I want to clone a repository from Github. It has lot of history so I'd like to clone without any history.
Is this possible?
I want to clone a repository from Github. It has lot of history so I'd like to clone without any history.
Is this possible?
You can get a shallow clone using the --depth
option with value 1
git clone --depth 1 reponame.git
If you want more commit history, increase the value to meet your needs as required.
After cloned, you can delete the .git
directory, then re-init the git to generate a totally new repo.
$ git clone ...
$ cd path/to/repo
$ rm -rf .git
$ git init
Use the --depth
option in git clone
:
--depth
<depth>
Create a shallow clone with a history truncated to the specified number of revisions.
Usage: git clone --depth 1 <remote_repo_url>
And in future if you want your shallow clone to have full history then you can unshallow it using this command
git fetch --unshallow