{"id":13731772,"url":"https://github.com/belak/gitdir","last_synced_at":"2025-05-07T09:45:42.477Z","repository":{"id":46080270,"uuid":"215666635","full_name":"belak/gitdir","owner":"belak","description":"PoC of a self-contained, simple, and lightweight SSH git hosting with just a directory.","archived":false,"fork":false,"pushed_at":"2024-04-19T13:20:32.000Z","size":185,"stargazers_count":182,"open_issues_count":10,"forks_count":3,"subscribers_count":6,"default_branch":"main","last_synced_at":"2024-10-19T05:51:31.274Z","etag":null,"topics":["git","golang","ssh"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/belak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-10-17T00:05:06.000Z","updated_at":"2024-07-04T07:18:50.000Z","dependencies_parsed_at":"2024-03-13T22:41:03.067Z","dependency_job_id":"7870192f-12a2-4c56-8109-03dcdcbe5e07","html_url":"https://github.com/belak/gitdir","commit_stats":null,"previous_names":["belak/go-gitdir"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/belak%2Fgitdir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/belak%2Fgitdir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/belak%2Fgitdir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/belak%2Fgitdir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/belak","download_url":"https://codeload.github.com/belak/gitdir/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252854163,"owners_count":21814639,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["git","golang","ssh"],"created_at":"2024-08-03T02:01:38.120Z","updated_at":"2025-05-07T09:45:42.459Z","avatar_url":"https://github.com/belak.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# go-gitdir\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/belak/go-gitdir)](https://goreportcard.com/report/github.com/belak/go-gitdir)\n[![Build Status](https://github.com/belak/gitdir/actions/workflows/test.yml/badge.svg)](https://github.com/belak/gitdir/actions/workflows/test.yml)\n\nThis project makes it incredibly easy to host a secure git server with a config\nthat can be easily rolled back.\n\nIt aims to solve a number of problems other git servers have:\n\n- Requires no external dependencies other than the binary and git\n- Stores its configuration in a repo managed by itself\n- Doesn't hook into the system's user accounts\n- No vendor lock-in - everything is just a bare git repository\n\n## Origins\n\nThe main goal of this project is to enable simple git hosting when a full\nsolution like Bitbucket, Github, Gitlab, Gitea, etc is not needed.\n\nThis project was inspired by gitolite and gitosis, but also includes a built-in\nssh server and some additional flexability. It is not considered stable, but\nshould be usable enough to experiment with.\n\nThankfully because all the repos are simply stored as bare git repositories, it\nshould be fairly simple to migrate to or from other git hosting solutions. There\nis no vendor lock-in.\n\n## Requirements\n\nBuild requirements:\n\n- Go \u003e= 1.13\n\nRuntime requirements:\n\n- git (for git-receive-pack and git-upload-pack)\n\n## Building\n\nClone the repository somewhere, outside the GOPATH. Then, from the root of the\nsource tree, run:\n\n```\ngo build ./cmd/gitdir\n```\n\nThis will create a binary called `gitdir`.\n\n## Running\n\n### Server Config\n\nThere are a number of environment variables which can be used to configure your\ngo-git-dir instance.\n\nThe following are required:\n\n- `GITDIR_BASE_DIR` - A directory to store all repositories in. This folder must\n  exist when the service starts up.\n\nThe following are optional:\n\n- `GITDIR_BIND_ADDR` - The address and port to bind the service to. This\n  defaults to `:2222`.\n- `GITDIR_LOG_READABLE` - A true value if the log should be human readable\n- `GITDIR_LOG_DEBUG` - A true value if debug logging should be enabled\n- `GITDIR_ADMIN_USER` - The name of an admin user which the server will ensure\n  exists on startup.\n- `GITHUB_ADMIN_PUBLIC_KEY` - The contents of a public key which will be added\n  to the admin user on startup.\n\n### Runtime Config\n\nThe runtime config is stored in the \"admin\" repository. It can be cloned and\nmodified by any admin on the server. In it you can specify groups (groupings of\nusers for config or convenience reasons), repos, and orgs (groupings of repos\nmanaged by a person).\n\nAdditionally, there are a number of options that can be specified in this file\nwhich change the behavior of the server.\n\n- `implicit_repos` - allows a user with admin access to that area to create\n  repos by simply pushing to them.\n- `user_config_keys` - allows users to specify ssh keys in their own config,\n  rather than relying on the main admin config.\n- `user_config_repos` - allows users to specify repos in their own config,\n  rather than relying on the main admin config.\n- `org_config_repos` - allows org admins to specify repos in their own config,\n  rather than relying on the main admin config.\n\n## Usage\n\nSimply run the built binary with `GITDIR_BASE_DIR` set and start using it!\n\nOn first run, gitdir will push a commit to the admin repo with a sample\nconfig as well as generated server ssh keys. These can be updated at any time\n(even at runtime) but if the server restarts and the keys cannot be loaded, they\nwill be re-generated.\n\nIf you set `GITDIR_ADMIN_USER` and `GITHUB_ADMIN_PUBLIC_KEY` an admin user will\nautomatically be added to the config.\n\nIf you do not set those environment variables, you will need to manually clone\nthe admin repository (at `$GITDIR_BASE_DIR/admin/admin`) to add a user to\n`config.yml` and set them as an admin.\n\n## Sample Config\n\nSample admin `config.yml`:\n\n```\nusers:\n  belak:\n    is_admin: true\n    keys:\n      - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDeQfBUWIqpGXS8xCOg/0RKVOGTnzpIdL7r9wK1/xA52 belak@tmp\n    repos:\n      personal-gitdir: {}\n\ngroups:\n  admins:\n    - belak\n\nrepos:\n  go-gitdir:\n    public: true\n\n    write:\n      - $admins\n    read:\n      - some-other-user\n\norgs:\n  vault:\n    admins:\n      - $admins\n    write:\n      - some-org-user\n    read:\n      - some-other-org-user\n\n    repos:\n      the-vault:\n        write:\n          - some-repo-access-user\n\noptions:\n  implicit_repos: false\n  user_config_keys: true\n  user_config_repos: false\n  org_config_repos: false\n```\n\n## Repo Creation\n\nAll repos defined in the config are created when the config is loaded. At\nruntime, if implicit repos are enabled, trying to access a repo where you have\nadmin access will implicitly create it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbelak%2Fgitdir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbelak%2Fgitdir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbelak%2Fgitdir/lists"}