3

I would like to 'git clone' from a remote repository with boilerplate code, but treat it as new repository created via 'git init', meaning I don't want it to have remote/origin and any commit history.

Basically what I want to achieve is in effect similar to doing:

git clone [remote_url]
rm -r .git
git init

But I am wondering if there is a git way to do it.

  • 1
    This seems an esoteric thing to want, so I imagine there's not a built-in way to do it. What's the use-case here? – Oliver Charlesworth Jul 08 '14 at 20:32
  • I think your question is answered here: http://stackoverflow.com/questions/9683279/make-the-current-commit-the-only-initial-commit-in-a-git-repository – McLovin Jul 08 '14 at 20:34
  • Oli Charlesworth: I have a repository with code that I usually use for new applications, but I want to treat every new app as new. Perhaps this is achieved in a different way? – eloquent_poltergeist Jul 08 '14 at 20:46

1 Answers1

1

The closest that I can imagine to what you want is to do a shallow clone, and then remove the remote manually.

git clone --depth 1 [remote_url]
git remote rm origin

If you then check git log, you'll see only one commit.

The last commit message will remain; if you want to remove it do git commit --amend.

tbekolay
  • 17,201
  • 3
  • 40
  • 38