Template repositories can reside on GitHub and should be named with the
suffix .g8
. We’re keeping a list of templates on the wiki.
To apply a template, for example, unfiltered/unfiltered.g8:
$ g8 unfiltered/unfiltered.g8
Giter8 resolves this to the unfiltered/unfiltered.g8
repository and queries GitHub for the project’s template
parameters.
Alternatively, you can also use a git repository full name
$ g8 https://gitlab.com/unfiltered/unfiltered-gitlab.g8.git
or even a local template, using the file://
protocol:
$ g8 file://path/to/template
For remote or local repositories it’s possible to fetch a specific branch, a specific tag or even a specific directory using command-line arguments:
-b, --branch <value> Resolve a template within a given branch
-t, --tag <value> Resolve a template within a given tag
-d, --directory <value> Resolve a template within the given
subdirectory in the repo
The default enclosing directory is .
.
You’ll be prompted for each parameter, with its default value in square brackets:
name [My Web Project]:
Enter your own value or press enter to accept the default. After all values have been supplied, giter8 fetches the templates, applies the parameters, and writes them to your filesystem.
If the template has a name
parameter, it will be used to create base
directory in the current directory (typical for a new project).
Otherwise, giter8 will output its files and directories into
the current directory, skipping over any files that already exist.
An output directory can be specified:
-o, --out <value> Output directory
this will override the generation of the directory’s name according to the value
of the name
variable and the current directory as the enclosing one.
To overwrite existing files in the destination folder, you can use:
-f, --force Force overwrite of any existing files in
output directory
Once you become familiar with a template’s parameters, you can enter them on the command line and skip the interaction:
$ g8 unfiltered/unfiltered.g8 --name=my-new-website
Any unsupplied parameters are assigned their default values.
Giter8 will use your ssh key to access private repositories, just like git does.
Giter8 now support proxying to an SSH Agent which can be useful if you are using another SSH agent
such as gpg-agent
.
Consider the following example:
~/.gitconfig
:
[url "ssh://git@github.com"]
insteadOf = https://github.com
~/.profile
:
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
gpgconf --launch gpg-agent
Then this would have previously failed with:
$ g8 unfiltered/unfiltered.g8
ssh://git@github.com/unfiltered/unfiltered.g8.git: Auth fail
This now works provided that the GitHub public key is in your known hosts file.
You can do this by running:
$ ssh -T git@github.com
Optionally the known hosts file can be overridden using:
-h, --known-hosts <value> SSH known hosts file. If unset the location
will be guessed.