1

I have a repo A which is a template project which contains a submodule. I want to be able to clone this repository and start a new project using this template project.

This command works, but it gives me a repository initialized with the latest commit of the repo A.

git clone --recursive <url>

I would prefer to clone the repo and then commit with a custom relevant message like "init from template project" as the first commit, and not the lastest submodule commit message.

This answer says I should do (I added --recursive to clone submodules):

git clone --recursive --depth=1 --branch=master git://someserver/somerepo dirformynewrepo
rm -rf !$/.git

After that I tried:

git init
git submodule init
git commit -m "init from template"
git push

Every submodules files are not recognized as beeing a submodule, and commited as normal files. How can I avoid that?

Aulaulz
  • 459
  • 4
  • 15

1 Answers1

0

A

git checkout --orphan new-branch
git commit -m 'init from template project'

starts a new branch without the history. When you still want the history, just create a commit with

git commit --allow-empty  -m 'init from template project'

You can also rewrite the top with

git commit --amend -m 'init from template project'
ensc
  • 6,704
  • 14
  • 22