16

Can I create my own remote server instead of using GitHub?

i.e Can I make a remote server on LAN where 3 computers are sharing a drive on a network to do the collaborative work using Gitbash?

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
Umair Cheema
  • 403
  • 2
  • 6
  • 14
  • 8
    This question is not off-topic, setting up a local network git server is a valid programmer's question. I've asked it myself, but it was for Windows specifically - https://stackoverflow.com/questions/18873297/self-host-remote-git-repository-on-windows-server/18890410#18890410 – sashoalm Apr 07 '16 at 13:58

3 Answers3

11

There are several ways to do this

  1. Host internal repositories like Gitlab or Stash. This will be similar to services like BitBucket or GitHub
  2. If you want to have a simple service with SSH authentication - user3159253 has already answered that
  3. A very bare bones way is
    1. server: Create a bare repo: mkdir -p RepoName && git init RepoName --bare
    2. server: Start the git daemon: git daemon --base-path=$PWD/RepoName
    3. client:
      Add your remote: git remote add origin git://server.url.or.ip/RepoName
      or just clone it: git clone git://server.url.or.ip/RepoName
hobs
  • 18,473
  • 10
  • 83
  • 106
First Zero
  • 21,586
  • 6
  • 46
  • 45
  • 4
    To be clear, where you've said `git remote add RepoName ...`, that is not the name of the repo, i.e. the project, but the name of the remote. "origin" not "helloworld-prog", for example. – OJFord Jul 27 '16 at 12:34
  • 1
    Nope: git clone git://192.168.0.12/gitrepo Cloning into 'gitrepo'... fatal: remote error: access denied or repository not exported: /gitrepo – Dean Schulze Sep 03 '20 at 20:46
  • 1
    The `access denied or repository not exported` happened to me because, `--base-path` should be `$PWD` instead of `$PWD/RepoName`. – Andrei Jun 01 '22 at 01:49
3

Yes, you do. Actually you need a SSH-service and git would perfectly work over SSH. Since you're on Windows, see Setup a Git server with msysgit on Windows

Community
  • 1
  • 1
user3159253
  • 16,836
  • 3
  • 30
  • 56
2

You can set up a remote repository and make it accessible through any of the protocols it supports. The AAA would be handled by the transport.

Noufal Ibrahim
  • 71,383
  • 13
  • 135
  • 169