假设当前分离的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: HEAD@{1}: checkout: moving from A to B
git switch -c branchname A
, orgit 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
. 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. Can use different numbers, of course:
git log HEAD@{1}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.