Skip to content

Instantly share code, notes, and snippets.

@physacco
Created May 16, 2013 06:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save physacco/5589886 to your computer and use it in GitHub Desktop.
Save physacco/5589886 to your computer and use it in GitHub Desktop.
Move the `origin' of a git repository to another host.

把一个git仓库的origin搬到另一台服务器上

  1. 在旧服务器上删除这个仓库

    rm -r /home/$USER/repo/$REPO

  2. 在新服务器上创建一个同名的仓库

    cd /home/$USER/repo git init --bare $REPO

  3. 在客户端修改origin地址,然后重新push

    git remote set-url origin ssh://$USER@$HOST:$PORT/home/$USER/repo/$REPO git push origin master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment