gitpocket
gitpocket is a self hosted git server in one static Go binary that serves repositories over SSH and HTTPS with a web interface rendered on the server. It idles at about 25 MB resident so it fits comfortably on a 512 MB VPS next to the git processes it starts.
Quick start
git clone https://gitpocket.io/~gitpocket/gitpocket && cd gitpocket
useradd -r -m -d /srv/gitpocket -s /bin/sh git
printf 'GITPOCKET_HOST=git.example.org\nGITPOCKET_UID=%s\nGITPOCKET_GID=%s\n' $(id -u git) $(id -g git) > deploy/.env
docker compose -f deploy/compose.yaml up -d
The web interface is then on 127.0.0.1:3200 and wants a reverse proxy with TLS in front of it. Sign up and then make yourself an administrator with docker exec gitpocket gitpocket admin you. INSTALL.md covers the Docker and binary installs, nginx, SSH, mail, backups and upgrades in order.
Features
- Public, unlisted and private repositories under
~user/name, with tree, log, blame, compare, history search and tar.gz or zip downloads of any ref - Branches, a branch switcher on every file view and a notice when a branch with new commits was pushed that links straight to a new pull request
- Markdown in pull requests, issues and comments with a preview tab and images you paste, drop or attach
- Pull requests from a branch or a fork with inline review, range diffs between force pushes and merge, squash or rebase without a working tree
- Organisations, collaborators, issues, labels, stars, forks, branch protection and per owner disk quotas enforced during the push
- Profiles with a pinned repository list, an activity graph, followers and a README from your
~you/yourepository - Imports from GitHub, GitLab, Gitea or Forgejo over https, with the option to credit commits made under your old identity to your account
- Pull mirrors that fetch a source on a schedule and stay read only and push mirrors that copy every branch and tag to another host after each change
- Static sites served from
<user>.<host>, built from apagesrepository or thepagesbranch of any public repository - Reports to admins and per account blocking, with hourly limits on new issues, pull requests and repositories
- SSH and PGP commit verification, TOTP, access tokens and Atom feeds for commits, issues and pull requests
- Site search over repositories and people with language facets
- Light and dark themes, light by default, with an option to follow the device
- A notification bell for activity on pull requests and issues you take part in
- Open, invite only or closed registration and an
/adminpage for accounts, invites, the front page and storage
There is no wiki and no CI and neither is planned.
Design
Every read of git data calls the plumbing with a thirty second timeout so a large repository costs exactly what git says it costs and nothing is parsed out of packfiles in process. Ref tables, trees, summaries and languages are cached against the mtime of the refs, which means one stat after a push invalidates them and deleting the cache loses nothing.
Pull requests fetch the source into refs/pull/N/head of the target. Merges are merge-tree and commit-tree followed by an update-ref that names the old value so a push racing the merge button makes the merge fail instead of being overwritten. SQLite comes from the pure Go modernc port which is why a CGO_ENABLED=0 build needs nothing beside a system git.
Usage
git clone https://git.example.org/~you/repo
git clone [email protected]:~you/repo
SSH pushes need a key added under settings and HTTPS pushes take an access token or your password. To contribute to something you do not own, fork it, push a branch to the fork and open a pull request from that branch.
Pages
A public repository named pages is served at https://you.git.example.org/ from its pages branch when one exists and from the default branch otherwise, and any other public repository with a pages branch appears beneath it at /name/. Paths without an extension also try .html and directories serve their index.html, while a missing file serves the site's own 404.html with a 404 status when the site provides one. Symlinks and submodules are never followed and files over 32 MB are refused, accounts younger than a day have no site at all and admins can turn any site off from the admin page.
The pages origin never sets or reads cookies and the main site only uses __Host- cookies, so a script running on a user site can neither read a session from the main host nor plant a cookie that the main host would later accept.
Mirrors
Ticking keep it as a read only mirror on the import page turns the import into a pull mirror that fetches the source again every 1, 4, 8 or 24 hours and refuses pushes, web edits and merges in the meantime. Push mirrors are added under the repository settings with a URL, a username and a token, and they push with --force --prune whenever the refs change before retrying after ten minutes if a push fails. Every fetch and push checks the URL again and resolves it once to a public address that stays pinned for the whole transfer, with redirects refused and https as the only protocol allowed. Tokens are sealed with AES-GCM under mirror.key in the data directory so that a copy of the database on its own does not reveal any of them.
Development
go test ./...
The tests drive the real handler through httptest and cover each registration mode, cross site posts, private repositories, moved repositories, every merge strategy and Markdown injection payloads.
Licence
MIT. KaTeX is MIT as well and Source Sans 3 is under the OFL with both notices kept beside the files.