Create custom directories when initializing a Git repo

65 Views Asked by At

I want to have the same structure in all new Git repos, for example:

repo
|- .git (created by git-init)
|- src
|- doc
|- README

Of course, in *nix I can have something like alias ginit="git init && mkdir ... && touch ..."

Can I have some kind of hook for git-init to create the dirs and a file only by means of Git itself? As far as I understand, --template= changes the structure of .git only.

1

There are 1 best solutions below

2
On

Have you considered using git aliases? e.g. (untested):

$ git config --global alias.ginit '!git init && mkdir src && mkdir doc && touch README'
$ git ginit