版权声明:转载请附明原文链接 https://blog.csdn.net/songyuequan/article/details/83714695
Git仓库.git文件夹目录介绍
在这篇文章中我们介绍了HEAD和refs的一些引用关系。
git reflog 顾名思义,就是查看ref的日志。也就是包含了所有ref变化的记录。
根据Git仓库.git文件夹目录介绍
我们可以得知,引起ref变化的操作有
- git checkout branchName ( 切换分支 ) :moving from branch1 to branch2
- git commit ( 提交 )
- git reset commit (重置)
- git checkout commit (签出某一个提交)
- git merge (合并操作)
- git pull (相当于 fetch + merge )
- git pull : Fast-forward ( 没有冲突,快速前进)
- git rebase (褊急)
- git pull --rebase ( 相当于fetch + rebase )
- git clone ( 初始化ref )
这些所有的操作都会显示在git reflog 中,也就是说git reflog 中保留了从clone仓库开始用户所有的操作。所以删除的分支中的commits 也会保留在reflog 中。进而我们可以用git reflog 来找回删除的commits。
git reflog
git checkout <reflog-Id>
git checkout -b <newBranchName>