7

If I want to use for example the Electron Quick Start as the base of a new app, should I use a normal clone and just delete the .git folder, or is there a more elegant way of doing it?

8

If I understand you correctly, you want to use this repo as a template, to begin a new project, not expand on an existing product. You're not interested in history, only a snapshot starting point.

In that case, deleting the .git folder and starting over with a new git init would be the simplest solution, IMO.

  • I'm an engineer, this suggestion follows the engineer rule KISS :) – Christian Wattengård Apr 27 '16 at 10:39
5

Instead of doing a full clone only to delete the .git directory again, you can only retrieve the archive of the repository you want to start from.

$ mkdir new-project/
$ cd new-project/
$ git archive --remote="${giturl}" HEAD | tar -x
$ git init
$ git add -A
$ git commit -m "Staring off with revision ${rev} of repository ${repo}."

See git help archive for more information.

  • This answer is fine, but it should contain a note it works only in an environment where tar is available. – Doc Brown Jan 3 '18 at 15:38
  • You can also use the download zip option that github and most git services provide. – Qwertie Jan 4 '18 at 5:13
  • You could also use clone but with "--depth 1" to prevent it pulling down all the history. You'd still need to delete the .git directory afterwards, but it would save you some time/bandwidth. – Sean Burton Jan 4 '18 at 14:19
2

Late to the answer game, but I have found out about git checkout --orphan recently, and this seems like the perfect scenario.

Running git checkout --orphan <branch_name> allows you to start a new branch based on an existing branch, but there will be no commit history. It's like doing git init on a new project folder.

One good use-case is for deploying gh-pages and for repos that have a branch for the deployed site: https://robots.thoughtbot.com/its-for-the-orphans

0

You can fork the repository in github and rename the forked repository something more appropriate for your application.

Alternatively you could clone the repository, and change the origin remote to the repository of your application or add your repository as a new remote.

  • 5
    If you fork or clone you (normally) keep the history. That may not be what the OP wants if he just wants to use a random project as a start template. – Andres F. Mar 18 '16 at 22:46

protected by gnat Jan 3 '18 at 16:10

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.