Git push/clone to new server

前端 未结 5 1167
别跟我提以往
别跟我提以往 2020-12-12 09:19

I\'m just learning Git and there is something I can\'t work out. After creating and using a git repository locally on my Mac, can I push a copy to another server somewhere e

5条回答
  •  情深已故
    2020-12-12 09:56

    What you may want to do is first, on your local machine, make a bare clone of the repository

    git clone --bare /path/to/repo /path/to/bare/repo.git  # don't forget the .git!
    

    Now, archive up the new repo.git directory using tar/gzip or whatever your favorite archiving tool is and then copy the archive to the server.

    Unarchive the repo on your server. You'll then need to set up a remote on your local repository:

    git remote add repo-name user@host:/path/to/repo.git #this assumes you're using SSH
    

    You will then be able to push to and pull from the remote repo with:

    git push repo-name branch-name
    git pull repo-name branch-name
    

提交回复
热议问题