How do I move my local Git repository to a remote Git repository

后端 未结 8 1629

I have various Git projects that are on my local machine. I have a server that I would like to use as my remote Git Repository. How do I move my local Git Repositories (Pro

8条回答
  •  日久生厌
    2020-12-07 09:22

    Create a git repository on the server (you can use gitolite/gitosis or just a normal user account + pubkey ssh auth), add the server to your local git repository using

    git remote add name url
    

    and use git push -u name master (-u marks the current branch as tracking so you can just git pull instead git pull name master).

    On the server side (debian based system):

    adduser --system --home /home/git --bash /bin/bash git
    su - git
    mkdir .ssh
    cat yourkey.pub > .ssh/authorized_keys
    

    Now, create a new bare repository for each local repository using

    mkdir projectName
    cd projectName
    git init --bare
    

    After that, the url would be git@yourserver:projectName.

提交回复
热议问题