22

I downloaded Git setup and trying to setup for computers in my network. I searched for the process but I found it for to host code on line on github.com. I found a few links but there is not the whole process.

I am aware for how to push and pull.

Biffen
  • 5,354
  • 5
  • 27
  • 32
Piyush
  • 3,697
  • 7
  • 31
  • 63
  • What do you mean by `whole process`? Do you need the command to setup a server and clone the repo? – Jan Mar 03 '15 at 09:11
  • I installed GIT now I want create one central repository and access it via my other computers. But I don't how. I am aware for how to push and pull only – Piyush Mar 03 '15 at 09:13
  • 1
    Which protocol do you want to use? There are http, ssh and git available, which all have different properties. – Rudi Mar 03 '15 at 09:25
  • http will be batter because I am aware it than other. – Piyush Mar 03 '15 at 09:29
  • Did you ever found out how to do it ? I am searching for the same thing. As someone with no knownledge at all of git, it is hard to find anything that starts from the beginning and has ALL the steps explained – GuidoG May 11 '21 at 11:55

5 Answers5

17

To create a new repository

  1. Create directory using git bash or create manually
  2. User following commands to create repository

    cd /repo/path/projectname.git
    git init --bare
    
  3. After initialize directory share the directory and grant all permission to local group

To create a local workspace

  1. Create another local repository for local user or other computer use following commands in same order

    cd ~/workspace/local/path
    
    git init
    
    git clone user@gitserver:/path/to/your/folder
    
    git add origin repo/path 
    
    git add .
    
    git status
    
    git commit
    
Biffen
  • 5,354
  • 5
  • 27
  • 32
JoyTree
  • 268
  • 1
  • 8
  • 2
    what does repo/path on add origin refer to? i cant seem to make it work it always error – Roi Oct 03 '17 at 03:05
  • @Roi did you get anywhere with this? Having the same issue. – Notts90 supports Monica Oct 09 '19 at 12:26
  • @Notts90 yes! basically your git repo should always be "bare" then you clone that repo as a working branch to your working computers – Roi Oct 10 '19 at 07:36
  • what software do I need on the server ? what software do I need on the development PC ? How to make them find eachother ? There are no answers in here, only more questions. Is there really no documentation that will help someone that has no knowledge at all of git that can get him started ? – GuidoG May 11 '21 at 11:54
11

If you're asking about how to connect to a repository hosted by another computer on the same network, take a look at this StackOverflow thread.

Basically, you'll want to use git daemon. If you just need to set up a single repository, that's one line from each machine:

Server:

git daemon --base-path=/path/to/repo --export-all

Client:

git remote add LocalServerName git://<serveraddress>/

or

git clone git://<serveraddress>/

where <serveraddress> is some reference to that machine (IPv4, IPv6, .local, etc.). You can also specify --verbose for the daemon command for more detailed output.

I think, also, you could have --base-path point to a folder with many repositories, and that would let you specify which project you wanted on the client-side like so:

git daemon --base-path=/path/to/all/repos

git remote add ServerName git://<serveraddress>/MyProject/

Be advised: using --export-all will let any computer on the network pull from your repo.

JJ Brown
  • 489
  • 6
  • 12
  • [jack@nasa git]$ git daemon --base-path=/home/jack/git --export-all [11067] Could not bind to 0.0.0.0: Address already in use – Ivanovic Nov 20 '20 at 17:39
7

You have to create a repository on the server side. Go to the folder which should be the repository and execute:

git init --bare

Then you have to clone the repository on your client with:

git clone user@gitserver:/path/to/your/folder

Watch this for further information.

Jan
  • 894
  • 5
  • 22
0

It is just easy as 1, 2, 3, 4:

1) Go to folder, where you want to initialize server(e.g: c:\temp).

2) Open git bash in this folder.

3) Type:

git init projectName --bare   // e.g => git init test --bare

well,You’ve just set up your server!

4) Choose where you want to initialize client repository and open git bash there.

Type:

git clone path/projectName  // e.g => git clone c:/temp/test

IMPORTANT! DO NOT FORGET TO CHANGE BACKSLASH (\) IN THE PATH TO DIRECT SLASH(/).

You can use this repository as usual and open it with your favorite git client.

connect to this server from another computer in local network:

(in windows 7) Firstly go to Control Panel > Network And Sharing Center > Change advanced sharing settings. Tick turn on network discovery.

Then go to folder where you have set up server and share it with users that you want to give permission for accessing it.

then Type:

git clone //ip/projectName   // e.g => git clone //192.168.11.125/test

I hope is useful.

AminRostami
  • 1,585
  • 1
  • 15
  • 33
  • git is not recognized as an internal command. Please is there no documentation that has ALL the steps ? – GuidoG May 11 '21 at 11:56
  • @GuidoG, the main command is `git init projectName` with option `--bare` , that `--bare` Create a bare repository. If GIT_DIR environment is not set, it is set to the current working directory. the other steps is normally commands. – AminRostami May 12 '21 at 03:29
  • and what software do I need ? I don't have git yet. I don't want to use git on the internet, I need git here at my local network and it should never ever connect to internet. So what do I need from software and how does it works ? – GuidoG May 12 '21 at 05:30
  • @GuidoG, the top solution only needed to install the `git`, ofcourse you can use the offline git server. for example `Bonobo Git Server` (for windows os). use this link for download: `https://bonobogitserver.com/`. download and create new website in local server and copy the downloaded file to your website and enjoy. – AminRostami May 12 '21 at 12:07
0

From JJ-Brown's answer

Basically, you'll want to use git daemon.

For that, make sure to use Git 2.32 (Q2 2021): "git daemon"(man) has been tightened against systems that take backslash as directory separator.

See commit 9a7f1ce (25 Mar 2021) by René Scharfe (rscharfe).
(Merged by Junio C Hamano -- gitster -- in commit bde35a2, 08 Apr 2021)

daemon: sanitize all directory separators

Signed-off-by: René Scharfe
Acked-by: Johannes Schindelin

When sanitizing client-supplied strings on Windows, also strip off backslashes, not just slashes.

VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283