How to setup Git on local network?

假装没事ソ 提交于 2019-11-27 21:39:09

问题


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.


回答1:


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
    



回答2:


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.




回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/28827831/how-to-setup-git-on-local-network

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!