separate-git-dir

Vladimir Varankin
Aug 27, 2017 · 1 min read

Tonight I found out git’s --separate-git-dir flag.

An abstract from the git-init / git-clone man pages:

--separate-git-dir=<git dir>

Instead of initializing the repository as a directory to either $GIT_DIR or ./.git/, create a text file there containing the path to the actual repository. [..]

There are two facts that riveted me:

1. The well-known .git/ directory, that usually leaves inside your project’s root, can be replaced with a simple text file named, you guessed it, .git:

gitdir: /absolute/path/to/projects/bare/clone.git

2. One can place a cloned bare repository on an external volume, which is automaticaly synced (I’m used to Yandex.Disk) between dev stations.

Runnig git clone --separate-git-dit=/... or git init --saparete-git-dir=/... gives me an easy way to keep my own repositories private, while leaves the power of distributed source-code managment.

Another possible application might be to have a lightweight temporary copy of a project, which could be a common case for CI jobs of scripts.

)

Go Developer @ Adjust, Berlin https://vladimir.varank.in

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade