Oleksandr Smirnov
Oleksandr Smirnov
olexsmir@gmail.com write logs to file, so we could write logs in ssh shell, 1 month ago
olexsmir@gmail.com write logs to file, so we could write logs in ssh shell, 1 month ago
| 1 | # mugit |
| 2 | |
| 3 | A lightweight, self-hosted Git server that your cow will love. |
| 4 | |
| 5 | [See it in action!](https://git.olexsmir.xyz) |
| 6 | |
| 7 | ## Features |
| 8 | - Web interface — browse repositories, view commits, files, and diffs (no javascript required). |
| 9 | - Git Smart HTTP — clone over HTTPS (use SSH for pushing). |
| 10 | - Git over SSH — push and clone repos over SSH. |
| 11 | - Mirroring — automatically mirror repos from other forges (supports GitHub authentication). |
| 12 | - Private repositories — repos accessible only via SSH |
| 13 | - CLI — command-line for managing your repositories |
| 14 | |
| 15 | ## Quick install & deploy |
| 16 | |
| 17 | ```sh |
| 18 | git clone https://git.olexsmir.xyz/mugit.git |
| 19 | cd mugit |
| 20 | go build |
| 21 | |
| 22 | # or |
| 23 | go install github.com/olexsmir/mugit@latest |
| 24 | ``` |
| 25 | |
| 26 | For nixos, you can use our flake, see [my config](https://git.olexsmir.xyz/dotfiles/blob/master/nix/modules/services/mugit.nix) for reference. |
| 27 | |
| 28 | Start the server: |
| 29 | ```sh |
| 30 | # start server with default config lookup |
| 31 | mugit serve |
| 32 | |
| 33 | # start with a custom config path |
| 34 | mugit -c /path/to/config.yaml serve |
| 35 | |
| 36 | # mirror your repo from github |
| 37 | mugit repo new repo-name --mirror https://github.com/user/repo |
| 38 | ``` |
| 39 | |
| 40 | ## Configuration |
| 41 | |
| 42 | mugit uses YAML for configuration. By default the server looks for a configuration file in this order (override with `-c` / `--config`): |
| 43 | 1. `./config.yaml` |
| 44 | 2. `/etc/mugit.yaml` |
| 45 | 3. `/var/lib/mugit/config.yaml` |
| 46 | |
| 47 | |
| 48 | Durations follow Go's duration syntax (examples: `1h`, `30m`, `5s`). See: [https://pkg.go.dev/time#ParseDuration] |
| 49 | |
| 50 | Minimal configuration example: |
| 51 | |
| 52 | ```yaml |
| 53 | meta: |
| 54 | host: git.olexsmir.xyz |
| 55 | |
| 56 | repo: |
| 57 | dir: /var/lib/mugit |
| 58 | ``` |
| 59 | |
| 60 | Full example: |
| 61 | |
| 62 | ```yaml |
| 63 | server: |
| 64 | host: 0.0.0.0 # bind address (0.0.0.0 = all interfaces) |
| 65 | port: 5555 # HTTP port (defaults to 8080 when omitted) |
| 66 | log_file: /var/lib/mugit/mugit.log # where slog output is written (default: <repo.dir>/mugit.log) |
| 67 | |
| 68 | meta: |
| 69 | title: "My Git Server" # site title shown on index page |
| 70 | description: "A place for my projects" |
| 71 | host: git.example.com # used for clone URLs and go-import meta tag |
| 72 | |
| 73 | repo: |
| 74 | dir: /var/lib/mugit # directory with repositories |
| 75 | # Default README filenames (applied when omitted): |
| 76 | readmes: |
| 77 | - README.md |
| 78 | - readme.md |
| 79 | - README.html |
| 80 | - readme.html |
| 81 | - README.txt |
| 82 | - readme.txt |
| 83 | - readme |
| 84 | |
| 85 | # ssh: push/clone over SSH |
| 86 | ssh: |
| 87 | enable: true |
| 88 | user: "git" # user as which the app operates (default "git") |
| 89 | # Only these public keys can access private repos and push to others. |
| 90 | keys: |
| 91 | - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA...... |
| 92 | - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA...... |
| 93 | |
| 94 | # mirror: automatic mirrors of external repositories |
| 95 | mirror: |
| 96 | enable: true |
| 97 | interval: 1h # sync frequency |
| 98 | # Tokens can be provided directly, or read from environment/file: |
| 99 | # - literal: "ghp_xxxxxxxxxxxx" |
| 100 | # - from env: "$env:GITHUB_TOKEN" (will read $GITHUB_TOKEN) |
| 101 | # - from file: "$file:/abs/path/to/token.txt" |
| 102 | github_token: "$env:GITHUB_TOKEN" |
| 103 | |
| 104 | cache: |
| 105 | home_page: 5m # cache index/home page |
| 106 | readme: 1m # cache rendered README per repo |
| 107 | diff: 15m # cache computed diffs |
| 108 | ``` |
| 109 | |
| 110 | ## CLI |
| 111 | |
| 112 | ```sh |
| 113 | # start server |
| 114 | mugit serve |
| 115 | |
| 116 | # create new public repository |
| 117 | mugit repo new myproject |
| 118 | |
| 119 | # create new private repository |
| 120 | mugit repo new --private myproject |
| 121 | |
| 122 | # create a mirror of an external repository |
| 123 | mugit repo new myproject --mirror https://codeberg.org/user/repo |
| 124 | mugit repo new myproject --private --mirror https://github.com/user/repo |
| 125 | |
| 126 | # toggle repository visibility |
| 127 | mugit repo private myproject |
| 128 | |
| 129 | # show and set repository description |
| 130 | mugit repo description myproject |
| 131 | mugit repo description myproject "My awesome project" |
| 132 | ``` |
| 133 | |
| 134 | ## License |
| 135 | |
| 136 | mugit is licensed under the MIT License. |