search

Home  >  Q&A  >  body text

准备更换git托管,如何迁移原git仓库

要求能保留原先的commit记录,应该如何迁移呢?
同时,本地已经clone了原仓库,要配置成新的仓库地址,该如何修改呢?

大家讲道理大家讲道理2801 days ago694

reply all(7)I'll reply

  • 迷茫

    迷茫2017-04-21 10:58:56

    Check the name of the remote first

    git branch -r

    Assume your remote is origin, use git remote set_url to change the address

    git remote set-url origin remote_git_address

    Replace remote_git_address with your new warehouse address

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-21 10:58:56

    If you want to copy a source code from another Git hosting service to a new Git hosting server, you can follow the steps below.

    1). Clone a bare version repository from the original address, such as originally hosted on GitHub.

    git clone --bare git://github.com/username/project.git
    

    2). Then create a new project on the new Git server, such as GitCafe.

    3). Upload the code to the GitCafe server by image push.

    cd project.git
    
    git push --mirror git@gitcafe.com/username/newproject.git
    

    4). Delete local code

    cd ..
    
    rm -rf project.git
    

    5). Find the Clone address on the new server GitCafe and clone it locally.

    git clone git@gitcafe.com/username/newproject.git
    

    This method can retain all the content in the original repository.

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-21 10:58:56

    Make sure your local library is up to date and just push to the new remote. . .

    Git is distributed, and each repository can be used as a server. . .

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-21 10:58:56

    git commit -m "Change repo." # 先把所有为保存的修改打包为一个commit
    git remote remove origin # 删掉原来git源
    git remote add origin [YOUR NEW .GIT URL] # 将新源地址写入本地版本库配置文件
    git push -u origin master # 提交所有代码
    

    reply
    0
  • 黄舟

    黄舟2017-04-21 10:58:56

    Organize a branch, and then use the branch to create a new library.

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-21 10:58:56

    Like the 4th floor, very convenient. All tags and branches are there

    reply
    0
  • 黄舟

    黄舟2017-04-21 10:58:56

    Why not try to package the entire directory directly and unzip it on a new machine.
    Environment permissions are consistent, that’s fine.

    reply
    0
  • Cancelreply