Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clone git repository without history?

Tags:

git

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?

like image 985
Dilip Kumar Avatar asked May 02 '15 10:05

Dilip Kumar


People also ask

Does git clone get all history?

Cloning an entire repo is standard operating procedure using Git. Each clone usually includes everything in a repository. That means when you clone, you get not only the files, but every revision of every file ever committed, plus the history of each commit.

Can you erase git history?

If you commit sensitive data, such as a password or SSH key into a Git repository, you can remove it from the history. To entirely remove unwanted files from a repository's history you can use either the git filter-repo tool or the BFG Repo-Cleaner open source tool.

Can I clone an empty repository?

An empty repository contains no files. It's often made if you don't initialize the repository with a README when creating it. On GitHub.com, navigate to the main page of the repository. To clone your repository using the command line using HTTPS, under "Quick setup", click .


2 Answers

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.

like image 83
mathematician1975 Avatar answered Oct 02 '22 21:10

mathematician1975


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 
like image 34
Kjuly Avatar answered Oct 02 '22 20:10

Kjuly