Using a git repository as the base of a new project

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?

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.

1

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.

3

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.

1

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *