Git init

Git or: How I Learned to Stop Worrying and Love the VCS

Ah, Git, such a marvelous thing. What would we do today if Git did not exist?

If Linus Torvalds did not decide one day that he was annoyed with all the current revision control systems, the world would be a much darker place today.

It is an essential tool to know and use in the daily joy and struggles of being a software developer. And indeed, git will bring nothing but ecstatic joy if one uses it correctly.

Nevertheless even if one is not a software developer, this tool can be very crucial in endeavours. Granted it does not fare well with large files, but there are extensions for that and they open up Git to countless possibilities, be it writing, graphics, videos, etc.

Humble beginnings

All projects will start from somewhere and that somewhere is nothing.


To begin with Git, one must initialise a repository. One can do so by using the following command:

git init

This will result in a simple message:

Initialized empty Git repository in /home/krisfremen/project1/.git/

Baring it all (Bare Repos)

git init --bare
Initialized empty Git repository in /home/krisfremen/remoteproject

This will end up initialising the repo in the current directory instead of the usual .git directory.

Bare repos are useful for remote repos that one would push to and will not have a working directory with checked out files.


Git comes with a nifty feature that allows specifying an alternate source for the contents of the .git directory.

Git in itself uses a directory on the filesystem that usually resides in ‘/usr/share/git-core/templates’ which one can edit to suit their needs and preferences to be used as default initialisations of new repos.

These needs and preferences would come up in the form of hooks, be they pre-hooks, post hooks, commit message change hooks, repo description, or local excludes.

git init --template=/home/krisfremen/git-work-template/

In order to actually make a template, simply copy the default Git directory elsewhere and subsequently use that instead with the necessary changes.

cp -R /usr/share/git-core/templates ~/git-work-template

Changing the git directory

For most intents and purposes, one does not need to change the default name of the .git directory. But for the cases where it is necessary, use the following command:

git --separate-git-dir=.gitarchive

In case of re-initialising an already existing repo, this will move the current .git(or any other name), using the directory name specified in the command and create a .git text file with the location of the git directory that will be used as a Git symbolic link to the repository data.

n.b.: If a repository is already set up with a different git directory, moving it back to “.git” won’t be done by this command, for that simply delete the .git text field rename the git directory to .git


The whole purpose of git is distributed revision control, this ensures that the git repo and any files created henceforth are created with the proper filesystem permissions.


git --shared
git --shared=false
git --shared=true
git --shared=umask
git --shared=group
git --shared=all
git --shared=world # same as all
git --shared=everybody # same as all
git --shared=0770
git --shared=0750
git --shared=0700

Telling Git to quiet down

At the end of the commands, one can add a -q or –quiet to tell git to print only errors and warning messages.

git init -q
git init --quiet


Using git init is needed to get started with using Git.

As this series progresses, you will learn how to use git and how it can help you.