How to setup Git on local network?

前端 未结 4 1780
北恋
北恋 2020-12-09 04:01

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

相关标签:
4条回答
  • 2020-12-09 04:02

    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.

    0 讨论(0)
  • 2020-12-09 04:11

    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.

    0 讨论(0)
  • 2020-12-09 04:21

    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
      
    0 讨论(0)
  • 2020-12-09 04:21

    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.

    0 讨论(0)
提交回复
热议问题