Solution 1
If you want to rely on templates, as indicated in the post you link, using the template directory you should have different template directories, each one having its proper info/exclude
file, and use
git init -c --template=/path/to/template
Note that this won't create a .gitignore
file, but a .git/info/exclude
file, that stays local to this repo and won't be shared when pushed (not the case with .gitignore
)
Solution 2
If you don't want to bother with creating directories, but rather get predefined one from the GitHub .gitignore
ones, this quick script inits a repo, grabs gitignore from GitHub's predefined one, and makes a first commit with it.
Check available languages here, and be careful first letter must be capitalized.
#!/bin/sh
git init .
curl -o .gitignore --fail --show-error --silent --location https://raw.github.com/github/gitignore/master/$1.gitignore
git add .gitignore && git commit -m "added gitignore from GitHub"
Call the script git-init-more.sh
, chmod +x
it, and put it in your path, then you can invoke it like this:
$ git init-more Perl