Skip to content

Instantly share code, notes, and snippets.

@PotOfCoffee2Go
Last active September 4, 2020 09:39
Show Gist options
  • Save PotOfCoffee2Go/9d36a0332e05910dcce9f6f345786dc1 to your computer and use it in GitHub Desktop.
Save PotOfCoffee2Go/9d36a0332e05910dcce9f6f345786dc1 to your computer and use it in GitHub Desktop.
Setup git daemon allowing anonymous clone and push behind a firewall

Git server behind a firewall

It is handy to be able to quickly create a git repo server with anonymous clone and push access rights.
Note: Anyone!! with access to the server will be able to clone and push to the repo
Is super handy for personal use, in-house networks, or networks behind a firewall where security is less of an issue.

Server side

Create common repo directory

Create the server git directory
Create a test repo
Bring up the git server daemon

mkdir repos
cd repos
git init --bare --shared=all foo.git
git daemon --reuseaddr --base-path=. --export-all --verbose --enable=receive-pack

Client side

Set your git config to prevent hang on 'push'

Only need to do this once.
See stackoverflow

git config --global sendpack.sideband false

Clone the repo

  • For now assuming the server is on your machine (localhost)
  • If on another machine, change localhost to the IP or name of the server
git clone git://localhost/foo.git
cd foo

Create readme.md file using your chosen editor, then :

git add .
git commit -m "Initial Commit"
git push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment