https://github.com/harshkapadia2/git-server
A simple self-hosted Git server.
https://github.com/harshkapadia2/git-server
git git-server
Last synced: 8 months ago
JSON representation
A simple self-hosted Git server.
- Host: GitHub
- URL: https://github.com/harshkapadia2/git-server
- Owner: HarshKapadia2
- License: mit
- Created: 2023-06-28T04:27:38.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-02T17:34:16.000Z (over 2 years ago)
- Last Synced: 2024-10-11T11:27:08.290Z (over 1 year ago)
- Topics: git, git-server
- Language: Shell
- Homepage:
- Size: 6.84 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Git Server
A simple self-hosted Git server (SSH access only).
## Setup Instructions
- Clone this repository
```bash
$ git clone https://github.com/HarshKapadia2/git-server.git
```
- Run the [`setup` script](setup).
```bash
$ cd git-server/
$ ./setup --pwd --default-branch
# Or
$ ./setup --help
```
> NOTE:
>
> - The Git server lives in a new user (and group) called `git`.
> - Repositories have to be created in `/srv/git` **by the `git` user**.
> - Currently, only SSH access is supported.
## Script Arguments
The [`setup` script](setup) arguments
- `--pwd `
- Password for the Git server account. Used for SSH as well.
- Value: A string. An empty string is not allowed.
- Requirement: Always
- `--default-branch `
- Optionally specify the default branch that Git should use for the initial branch.
- Value: A string. Default value is `master`.
- Requirement: Optional
- `--help`
- Print this command usage instruction.
- Value: No value should be entered.
- Requirement: Optional
## Adding New Repositories
- Access the Git server and switch to the `git` user.
```bash
$ ssh git@server_hostname
```
- Create a new directory in `/src/git` with the name of the repository appended with a `.git`.
```bash
$ mkdir /srv/git/repo_name.git
```
- Inside the newly created directory, create a bare Git repository.
```bash
$ cd /srv/git/repo_name.git
$ git init --bare
```
## Resources
- [How to Create Your Own Git Server](https://www.inmotionhosting.com/support/website/git/git-server)
- [Git internals](https://git.harshkapadia.me)
- Bare Git repositories
- [What is a bare repository and why would I need one?](https://stackoverflow.com/questions/37992400/what-is-a-bare-repository-and-why-would-i-need-one)
- [all about "bare" repos -- what, why, and how to fix a non-bare push](https://htmlpreview.github.io/?https://github.com/sitaramc/sitaramc.github.com/blob/dce410b2a2804723676db9cabd7bb506b6d9ba05/concepts/bare.html)
- [What's the -practical- difference between a Bare and non-Bare repository?](https://stackoverflow.com/questions/5540883/whats-the-practical-difference-between-a-bare-and-non-bare-repository)