https://github.com/fenhl/gitdir
Keep your git repos organized
https://github.com/fenhl/gitdir
command-line-tool git python-library python3
Last synced: 22 days ago
JSON representation
Keep your git repos organized
- Host: GitHub
- URL: https://github.com/fenhl/gitdir
- Owner: fenhl
- License: mit
- Created: 2015-08-09T22:27:56.000Z (almost 11 years ago)
- Default Branch: main
- Last Pushed: 2023-09-10T07:56:14.000Z (over 2 years ago)
- Last Synced: 2025-09-10T17:59:41.611Z (9 months ago)
- Topics: command-line-tool, git, python-library, python3
- Language: Python
- Size: 48.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
**gitdir** is a system that helps you keep your git repositories organized. It is *not* a git workflow, and works with different (but not all) workflows. Gitdir is the successor to [hubdir](https://github.com/fenhl/hubdir), generalized to allow working with repositories that are not hosted on github.
This is gitdir version 3.0.0 ([semver](http://semver.org/)). The versioned API is described below, in the section *The system*.
# The system
This section describes the gitdir system.
## The directories
In the gitdir system, all git repos are organized within the *git directories*, or *gitdirs*. There are two kinds of gitdir:
1. the global gitdir at `/opt/git`, and
2. the local gitdirs at `~/git`. Each user can have their own local gitdir.
The global gitdir will be used by default, while the user's local gitdir is used only for staging and when the global gitdir is inaccessible.
## Directory structure
A gitdir contains subdirectories for any host from which repositories are cloned. The way repositories are organized within the host directory is defined individually for each host. For example, `github.com` organizes repositories by github username and repo name, so that the directory for this repo would be located at `/opt/git/github.com/fenhl/gitdir`.
Four different kinds of repos may reside within a repo directory:
1. Main repos, located at `/main` (fallback to `/master` for backwards compatibility). These track [the default branch](https://help.github.com/articles/setting-the-default-branch) from the remote and should always stay clean.
2. Branches, located at `/branch/`. These work like the main repos, except they track a different remote branch.
3. Stages, located at `/stage`. These have more loose restrictions and are where any work happens.
4. Bare repos, located at `/.git`. These are created with `git init --bare`, and should be used as the remote when hosting locally (`/opt/git/localhost`).
## Repo setup
Within a repo, the following rules should be, well, followed:
* All github repos have the default `origin` remote set up as follows:
* For main and branch repos, `https://github.com//.git`
* For stage repos, `git@github.com:/.git`
* Main and branch repos have no other remotes. For stages, do whatever works best for your git workflow.
* In multi-user environments, the global gitdir and everything under it should be owned by a group named `git` and be group read-writeable.