美文网首页
从.git文件夹恢复仓库文件

从.git文件夹恢复仓库文件

作者: imxiaochao | 来源:发表于2018-09-25 16:32 被阅读0次

    基于gitlab或者gitea的私有git仓库,有时会出现服务挂了,又没有办法进行备份恢复的情况下,只能进服务器找到默认存储的.git 文件夹,这时如何恢复仓库,找了很久资料总结出以下办法
    假设目前你只有一个隐藏的 .git 文件夹

    cd repo.git
    # 创建budele文件
    git bundle create ./reponame.bundle --all
    # 从bundle文件中clone出代码
    git clone ./reponame.bundle reponame
    # 这是文件夹内会出现一个 reponame 文件夹,这个文件夹内就是所有的代码文件
    # 并且还可以恢复其他分支的代码
    git clone -b release ./reponame.bundle reponame
    
    # 新建新的git仓库 名为 newrepo
    git remote rm origin
    # url.git 为新的git仓库地址
    git remote add origin newrepo.git
    
    

    搞定!

    相关文章

      网友评论

          本文标题:从.git文件夹恢复仓库文件

          本文链接:https://www.haomeiwen.com/subject/rnyloftx.html