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?
4 Answers
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– Christian Wattengård2016-04-27 10:39:56 +00:00Commented Apr 27, 2016 at 10:39
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
taris available.Doc Brown– Doc Brown2018-01-03 15:38:22 +00:00Commented Jan 3, 2018 at 15:38 - You can also use the download zip option that github and most git services provide.Qwertie– Qwertie2018-01-04 05:13:39 +00:00Commented Jan 4, 2018 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– Sean Burton2018-01-04 14:19:21 +00:00Commented Jan 4, 2018 at 14:19
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
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.
- 5If 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.– Andres F.2016-03-18 22:46:11 +00:00Commented Mar 18, 2016 at 22:46