20

我想恢复从 Bitbucket 上的远程共享存储库中删除的分支。我知道这reflog是使用本地存储库的方式。

我将如何在远程实现这一目标?

4

3 回答 3

31

四年后...

我遇到了这个答案,因为我通过 bitbucket.org UI 删除了团队成员想要恢复的分支。

我发现它git branch --remote显示了原点上的所有分支,甚至是那些通过 UI 删除的分支。

我用 本地检查了 origin 分支git checkout origin/<branch_name> -b <branch_name>,然后做了git push -u origin <branch_name>,它再次出现在 UI 中。

于 2017-05-04T21:28:53.623 回答
5

reflog is still the answer, except you don't have access to the reflog on the remote (Bitbucket ) side.

That means you need to write to Bitbucket support in order for them to restore what you need.

于 2013-03-24T11:10:45.173 回答
1

是的,这种方法完全有效。但我建议先检查此命令,然后再继续执行其他两个恢复分支:

git branch --remote 

如果您的分支显示在上述命令输出的列表中,请自信地执行以下操作:

git checkout origin/<branch_name> -b <branch_name>
git push -u origin <branch_name> 
于 2021-08-10T08:47:35.597 回答