Git 恢复误删除分支

背景

origin/feature/upgradeiOS14 分支被误删除,需要恢复

步骤

Step1

通过 git reflog 命令可查找本地仓储的所有commit

MacBook-Pro:TZImagePickerController XXX$ git reflog
f35ca34 (HEAD -> master, origin/master, origin/HEAD) HEAD@{0}: checkout: moving from feature/upgradeiOS14 to master
3167c4e HEAD@{1}: commit: [Fix] Xcode12 构建,iOS14运行,裁切手势不生效问题
f35ca34 (HEAD -> master, origin/master, origin/HEAD) HEAD@{2}: checkout: moving from master to feature/upgradeiOS14
f35ca34 (HEAD -> master, origin/master, origin/HEAD) HEAD@{3}: clone: from https://github.com/XXX/TZImagePickerController.git

通过Log可判定 3167c4e HEAD@{1} 节点为待恢复分支的头节点

Step2

执行以下命令,恢复误删除分支

MacBook-Pro:TZImagePickerController XXX$ git branch feature/upgradeiOS14 HEAD@{1}

你可能感兴趣的:(Git 恢复误删除分支)