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.
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:
This will result in a simple message:
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.
In order to actually make a template, simply copy the default Git directory elsewhere and subsequently use that instead with the necessary changes.
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:
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.
At the end of the commands, one can add a -q or –quiet to tell git to print only errors and warning messages.
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.