How to create a Git server on the internal network?

Asked

Viewed 14,692 times

7

You can create a Git local server?

I would not like to be dependent on the internet.

6 answers

10


There is! There is a chapter in the Git Pro book that covers this. The book is available online.

I recommend reading because there are several options. You may, for example, need authentication for read access or may require more server speed. For each of these choices, there is a recommended protocol. Github, for example, provides read access to public repositories via git protocol (lighter and faster). But for writing access from project commiters, it uses SSH (a bit heavier, but provides authentication). Another option is HTTP for reading, which makes it easy to traverse corporate firewalls.

Anyway, there are basically four options:

  • Local mapping
  • SSH
  • Git’s own protocol
  • HTTP

What you’ll choose (or whether you’ll choose a hybrid solution like Github) depends on your needs. So I recommend reading the book.

  • 4

    Even if this link is a good suggestion, this reply will not be valid if one day the link ceases to work. So, because it’s important for the community to have content here, you’d better respond with more complete answers. You can elaborate more your answer?

  • 1

    elaborate! recalling that the local mapping solution (which seems to be what the other answers are suggesting so far) is not always applicable to all situations.

3

To start a GIT repository anywhere, just type in:

git init

If the folder where this repository is is accessible local, usb, or network, it passes you will be able to push it to your other repository as remote.

For example, I have in my project folder and in my USB the same repository:

/home/gartz/projects/foo
$ git init

And also on my USB:

/media/usb_gartz/foo
$ git init

Now just register usb as remote in my personal project and it will be my GIT server /home/gartz/projects/foo

$ git remote add origin /media/usb_gartz/foo

Now whenever I give a push or fetch it will fetch on origin that in the case is the /media/usb_gartz/foo and is local.

You can add access via any protocol, SSH, SMB, FTP, etc if you want to give remote access to your server.

But if you don’t want a snapshot of your project on your local server, you can use Bare Repository which is nothing more than the folder .git which is created, you can copy it and point to it, just like in the example.

2

Adding to what Gabriel Gartz said: Git doesn’t have a centralized server. Git, like Mercurial for example, is a noncentralized repository. You don’t create a Git server, but a master repository - which can be any git repository on your network.

To do this, simply choose which machine on your network will be the "Canonical"/"master" repository, configure your IP/name correctly, and configure the other machines to push to it (i.e., it would be Master) as you would with Bitbucket/Github. Versioning processes will not change.

1

1

0

Unlike solutions like cvs and svn, Git is decentralized. You don’t need to have a fixed server. You can simply share a folder on the network and do push there. You can also put an ssh server on your internal network.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.