V
V
Valera Udav2016-04-22 14:14:55
git
Valera Udav, 2016-04-22 14:14:55

How to clone a git repository without a .git directory?

I have a starter package in my git for my projects. I would like to work in the following way:

  1. Create a new repository for a new project
  2. Clone it locally
  3. Cloning the structure of my start repository into the project
  4. Starting work on a project

There is a problem when cloning the repo of the starter package, the fact is that, of course, all the information of the .git directory is cloned along with it, but I only need the structure in an already existing project.
I found several solutions as a solution:
  • Download files manually through the github website and upload them to the project
  • Clone starter package repo, remove .git directory and copy files to project
  • Fork the starter pack as a repo for a new project
  • Clone the starter package and change its config to the project repo

But none of these methods is in my opinion completely correct. I would like to know how to solve this problem in a more correct way according to two conditions:
  1. Working through the console
  2. Minimum body movements

I'm almost sure that the problem is solved by one or two teams, but for some reason, googling did not give anything.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Danil Biryukov-Romanov, 2016-04-22
@urtow

Enough debauchery, dig out the stewardess.
You have already found the most correct solution - Fork the starter package as a repo for a new project.
As a result, in one move you get a new independent repo, with the same set of files.
If the soul forgive the strange and the stewardess does not want to dig out, you can simply transfer the repository to a new project like this:

# Клонируем исходный репозиторий без рабочего каталога (--bare)
git clone --bare https://github.com/exampleuser/old-repository.git
 
cd old-repository.git
# Делаем mirror-push(будут скопированы все ветки и тэги) в новый репозиторий
git push --mirror https://github.com/exampleuser/new-repository.git
 
cd ..
# Удаляем папку с репозиторием
rm -rf old-repository.git

However, there are actually extra movements.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question