How to create a Git server on the internal network?

6

How can I create a local Git server?

I would not want to be dependent on the internet.

    
asked by anonymous 31.01.2014 / 14:49

6 answers

10

Yes you do! You have a chapter in the book Pro Git 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 write access of 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.

Finally, there are basically four options:

  • Local mapping
  • SSH
  • git's own protocol
  • HTTP

What you will choose (or whether you will opt for a hybrid solution such as Github) depends on your needs. So I recommend reading the book.

    
31.01.2014 / 14:52
3

To start a GIT repository anywhere, just type:

git init

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

For example, I have in my projects folder and on 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 in my personal project the usb as remote 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 in the origin that in this case is /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 do not want a snapshot of your project on your local server, you can use the bare repository that is nothing but the .git folder that you create, you can copy it and point to it, just like in the example.

    
31.01.2014 / 14:59
2

Complementing what Gabriel Gartz said: Git does not have a centralized server. Git, like Mercurial for example, is a non-centralized repository. You do not create a Git server, but a master repository - which can be any git repository in 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 for it (ie, it would be Master ) as you would with Bitbucket / Github. Versioning processes will not change.

    
31.01.2014 / 15:02
1

You can prepare your own git server using GitLab or Gitorious .

    
31.01.2014 / 15:08
1

On your server you create the git directory by doing:

git init --bare

At the station where you are going to work, you only initialize with

git init 

Well, see more of an article I wrote in 2011, even though the old ones remain the same: link

    
18.06.2014 / 23:31
0

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

    
31.01.2014 / 15:00