Skip to content

Instantly share code, notes, and snippets.

View m-bartlett's full-sized avatar
⛓️

M B m-bartlett

⛓️
View GitHub Profile
@m-bartlett
m-bartlett / automatic-local-git-mirror-how-to.md
Last active June 26, 2021 06:28
How to configure a local-network machine that permits SSH access to automatically create git repos if it receives a `git push`.

Easy and Automatic Local Area Network Git Mirroring via SSH

Mirroring Remote Origin

A git user may add or modify a remote in their repository via the git remote subcommand. Most commonly (e.g. in the case the user has cloned from a popular git service such as GitLab or GitHub) git repositories have a remote named origin which is the default remote operated on. We can add extra URLs that point to other servers hosting a copy of the repository via git remote set-url --add origin <url>.

Alternatively, one can also manually edit .git/config in the root of the repository. An example of what may be in the config regarding the remote origin is

[remote "origin"]
  url = [email protected]:<user>/<repo_name>.git
  fetch = +refs/heads/*:refs/remotes/origin/*