Clone git repository without history?

Git

Git Problem Overview


I wanted clone repository from github. It had lot of history, So i wanted clone without any history.

Is it possible to clone git repository without history?

Git Solutions


Solution 1 - Git

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.

Solution 2 - Git

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

Solution 3 - Git

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>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDilip KumarView Question on Stackoverflow
Solution 1 - Gitmathematician1975View Answer on Stackoverflow
Solution 2 - GitKjulyView Answer on Stackoverflow
Solution 3 - GitInder Kumar RathoreView Answer on Stackoverflow