[英]What's the best way to find old detached HEAD after repo sync?
假设当前分离的HEAD上有一些本地提交(A,A1,A2,A3)指向提交A,在repo同步之后,本地分离的HEAD被指向提交B的远程最新分离的HEAD覆盖,什么是找到旧提交(A,A1,A2,A3)的最佳方法?
The simplest way I can imagine is:我能想象的最简单的方法是:
git reflog
to find A: git reflog
找到 A:HEAD@{1}: checkout: moving from A to B
git switch -c branchname A
, or为它创建一个新分支以防再次丢失: git switch -c branchname A
,或git rebase A
/ git merge A
, then you will see all A, A1, A2, A3
appear on the current HEAD once all conflictions(if any) are resolved, and don't forget to create a new branch with git switch -c
. rebase 或将其合并到当前 HEAD: git rebase A
/ git merge A
,一旦所有冲突(如果有)得到解决,您将看到所有A, A1, A2, A3
出现在当前 HEAD 上,不要忘记使用git switch -c
创建一个新分支。If there were no additional operations that moved HEAD around, you could use HEAD@{1}
to know the exact previous location of HEAD before current.如果没有移动 HEAD 的其他操作,您可以使用HEAD@{1}
了解 HEAD 在当前之前的确切位置。 Can use different numbers, of course:可以使用不同的数字,当然:
git log HEAD@{1}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.