Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在github中恢复已删除的分支_Git - Fatal编程技术网

如何在github中恢复已删除的分支

如何在github中恢复已删除的分支,git,Git,您的一位队友意外删除了一个分支,并且已经将更改推送到了中心git回购。没有其他git回购协议,您的其他队友也没有本地副本。您将如何恢复该分支机构?我想开发商仍然拥有其本地回购协议,对吗?Ternal在推动删除时应该有修订的id。。。使用该ID创建新分支 $ git reflog 1ed7510 HEAD@{1}: checkout: moving from develop to 1ed7510 3970d09 HEAD@{2}: checkout: moving from b-fix-build

您的一位队友意外删除了一个分支,并且已经将更改推送到了中心git回购。没有其他git回购协议,您的其他队友也没有本地副本。您将如何恢复该分支机构?

我想开发商仍然拥有其本地回购协议,对吗?Ternal在推动删除时应该有修订的id。。。使用该ID创建新分支

$ git reflog
1ed7510 HEAD@{1}: checkout: moving from develop to 1ed7510
3970d09 HEAD@{2}: checkout: moving from b-fix-build to develop
1ed7510 HEAD@{3}: commit: got everything working the way I want
70b3696 HEAD@{4}: commit: upgrade rails, do some refactoring
98f2fc2 HEAD@{5}: commit: a couple code cleanups
d09f35e HEAD@{6}: commit: remove test method - it served it's purpose and now it must go
d586a93 HEAD@{10}: commit: aha! that is why I'm so fail
4644046 HEAD@{11}: commit: cleaning up the initial migration for dev/test environments
323df37 HEAD@{15}: commit: bump ruby version
eab861c HEAD@{16}: commit: bundle update EVERYTHING
2b544c4 HEAD@{17}: commit: fixing what few tests actually exist - a.k.a., wow! does this app even work?
3970d09 HEAD@{18}: checkout: moving from develop to b-fix-build
3970d09 HEAD@{19}: pull: Fast-forward

Once you find the commit you're looking for, create a new branch from it and you're done!

$ git checkout -b branch-name 70b3696
Switched to a new branch 'branch-name'
git branch blah the-id
如果终端已经关闭,则检查该分支的最新版本。

最简单-查看队友本地回购的“git reflog”。您将在他上次签出分支时找到最后一个条目

如果它在本地丢失,您可能有权访问远程回购—请在那里查找悬空提交。请参阅此处的说明:


只需在找到的提交id的顶部创建一个新分支,下面的命令将显示提交列表

git fsck --full --no-reflogs | grep commit

从已删除的分支选择提交,签出

分支删除时,分支reflog将被删除,因此必须使用HEAD reflog完成此操作-这不是很容易,除非同事最近签出了分支的最新提交,否则根本不起作用。(我刚刚在2.10.1上验证了这一点,对于任何旧版本都是如此;如果它在最近的版本中发生了更改,那很好,但我不这么认为。)在删除分支时,终端不一定在分支提示提交上——事实上,我对此表示怀疑。这毫无意义。分支可以被删除,reflog不会改变,因为HEAD已经在那里了(如果是这样的话)。听起来像是一个考试题。