Git push/clone to new server

前端 未结 5 1153
别跟我提以往
别跟我提以往 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:37
    remote server> cd /home/ec2-user
    remote server> git init --bare --shared  test
    add ssh pub key to remote server
    local> git remote add aws ssh://ec2-user@<hostorip>:/home/ec2-user/dev/test
    local> git push aws master
    
    0 讨论(0)
  • 2020-12-12 09:39
    1. git remote add name url
    2. git push name branch

    Example:

    git remote add origin git@github.com:foo/bar.git
    git push origin master
    

    See the docs for git push -- you can set a remote as the default remote for a given branch; if you don't, the name origin is special. Just git push alone will do the same as git push origin thisbranch (for whatever branch you're on).

    0 讨论(0)
  • 2020-12-12 09:46

    You can push a branch to a remote server, say github. You would first have to do the initial project setup, then clone your project and:

    git push <remote repo> <your branch>
    
    0 讨论(0)
  • 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
    
    0 讨论(0)
  • 2020-12-12 09:57

    There are many ways to move repositories around, git bundle is a nice way if you have insufficient network availability. Since a Git repository is really just a directory full of files, you can "clone" a repository by making a copy of the .git directory in whatever way suits you best.

    The most efficient way is to use an external repository somewhere (use GitHub or set up Gitosis), and then git push.

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