如何从已删除的Git远程存储库中恢复

Mee*_*ite 2 git recovery gitlab gitlab-ce

我们在服务器的虚拟机上安装了Gitlab CE。
这个Gitlab服务器上有3个人在一个存储库中工作。
这个Gitlab CE虚拟机已被意外删除!这3个人的本地存储库仍然有很多分支机构。
我们的分支策略是这样的:
每个用户都有一个Master分支和一些功能分支。
用户过去曾:

  • 从远程拉主人,
  • 从中分支
  • 做出改变,
  • 再次推送至主服务器(通过合并请求)

现在,我有一些问题:

  1. 是否有任何方法策略可以从本地资源重建或重建远程仓库?
  2. 如果没有,我应该怎么做才能创建另一个远程仓库并合并所有提交?

Saj*_*han 5

  • 在GitLab / BitBucket / GitHub中创建一个空的仓库。

  • 使用新存储another库的URL在当前存储库中添加新的远程服务器(例如)。然后将master分支的提交/更改推送到another仓库的主分支。

    $ git remote add another <new-repo-url>
    $ git remote -v                 # see if the remote is added correctly 
    $ git checkout master
    
    $ git push another master       # push the changes to another/master
    
    Run Code Online (Sandbox Code Playgroud)
  • 如果您需要另一个分支的功能(例如feature),则只需checkout转到该feature分支,然后将更改推送到another仓库的feature分支即可。

    $ git checkout feature
    $ git push another feature      # push changes to 'another' repo's 'feature' branch
    
    Run Code Online (Sandbox Code Playgroud)
  • 推动所有的branchestagsanother回购。

    $ git push --all --tags another
    
    Run Code Online (Sandbox Code Playgroud)

注意:此处another代表您新仓库的URL。