您的一个队友不小心删除了一个分支,并且已经将更改推送到中央git存储库中。没有其他git仓库,您的其他队友都没有本地副本。您将如何恢复该分支?
答案 0 :(得分:0)
$ 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'
答案 1 :(得分:0)
我认为开发者 still 拥有他的本地仓库,对吗?当终端推送删除时,终端应具有修订版的ID ...使用该ID创建新的分支
git branch blah the-id
如果终端已经关闭,则检查git reflog
以获得该分支的最新版本。
答案 2 :(得分:0)
最简单-查看队友本地存储区的“ git reflog”。当他上次签出分支机构时,您会找到最后一个条目。
如果它在本地丢失,则可以访问远程存储库-在此处查找悬挂的提交。请参阅此处的说明:https://softwarebakery.com/recovering-commits-with-git
只需在找到的commit-id顶部创建一个新分支
答案 3 :(得分:0)
下面的命令将显示提交列表
git fsck --full --no-reflogs | grep commit
从已删除的分支中选择提交并检出