Quickly create a Git bare repo with init or clone example

A bare repository is one in which local development is not allowed.

This type of repository is useful if you are setting up a server to host your source code or perhaps implementing a backup strategy that replicates your source code to a safe, off-site location. You can think of the Git repositories hosted on GitHub or GitLab as bare repositories, as no local development happens directly on the GitHub or GitLab servers. These are bare Git repos whose sole purpose is to enable the distributed sharing of code.

Types of git bare repos

There are two ways to create a bare Git repo:

  1. Clone an existing repository with the git clone –bare switch.
  2. Create a new bare git repo with the git init –bare switch.

Obviously, you should use the bare git init approach when you are starting a brand new project. And use the clone when a Git repo is active and you want to create a backup or extra node point.

Create bare Git repo commands

Use these commands, as shown in the bare Git repo example:

git-clone@bare:~$ git clone --bare https://github.com/cameronmcnz/my-github-repo.git
git-clone@bare:~$ git init --bare .

You don’t  need to have an active development workspace or working tree on a Git repo that is acting purely as a remote Git hosting node. This would just force you to run Git clean up routines in the future. In such situations, it makes sense to create a bare Git bare repo.

git init bare

When you create a bare Git repo with init or clone, the working tree disappears and only implementation artifacts remain.

App Architecture
Software Quality
Cloud Computing