https://github.com/adamveld12/gittp
:octocat: Git HTTP backend in go
https://github.com/adamveld12/gittp
cli git golang
Last synced: 5 months ago
JSON representation
:octocat: Git HTTP backend in go
- Host: GitHub
- URL: https://github.com/adamveld12/gittp
- Owner: adamveld12
- Created: 2016-05-11T00:40:49.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2017-02-28T02:24:11.000Z (over 9 years ago)
- Last Synced: 2025-08-14T04:48:49.628Z (10 months ago)
- Topics: cli, git, golang
- Language: Go
- Size: 45.9 KB
- Stars: 13
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GITTP
[](http://godoc.org/github.com/adamveld12/gittp)
[](https://gowalker.org/github.com/adamveld12/gittp)
[](http://gocover.io/github.com/adamveld12/gittp)
[](https://goreportcard.com/report/github.com/adamveld12/gittp)
[](https://semaphoreci.com/adamveld12/gittp)
Host your own git server over HTTP. Effortlessly hook into pre and post receive events and write status updates back to the client.
Comes in CLI and Library flavors.
I used [this doc](https://www.kernel.org/pub/software/scm/git/docs/technical/http-protocol.html) and this handy [blog post](http://www.michaelfcollins3.me/blog/2012/05/18/implementing-a-git-http-server.html)
## How to CLI
Simply run `gittp` at your command line after installing the binary into your `$PATH`.
Available args:
`-port`: The port that gittp listens on
`-path`: Specify a file path where pushed repositories are stored. If this folder doesn't exist, gittp will create it for you
`-masterOnly`: Only permit pushing to the master branch
`-autocreate`: Auto create repositories if they have not been created
`-debug`: turns on debug logging
## How to Library
Install:
```
go get gopkg.in/adamveld12/gittp.v1
```
This lib follows http.Handler conventions. I purposely do not include any authentication, since there are many http basic authentication modules out there to use.
```go
package main
import (
"net/http"
"github.com/adamveld12/gittp"
)
func main() {
config := gittp.ServerConfig{
Path: "./repositories",
PreCreate: gittp.UseGithubRepoNames,
PreReceive: gittp.MasterOnly,
PostReceive: func(h gittp.HookContext, archive io.Reader){
h.Writef("Woohoo! Push to %s succeeded!\n", h.Branch)
}
}
handle, _ := gittp.NewGitServer(config)
log.Fatal(http.ListenAndServe(":80", handle))
}
```
## Contributing
All contributions, critiques and questions are welcome.
- [Git Guildines](https://github.com/thoughtbot/guides/tree/master/protocol/git)
- [How I Review Code](https://github.com/thoughtbot/guides/tree/master/code-review)
- [My Coding Practices](https://github.com/thoughtbot/guides/tree/master/best-practices)
- [My Style Guide](https://github.com/thoughtbot/guides/tree/master/style)
## License
MIT