[Git] Recover Local Changes from `git reset --hard` with `git reflog`
Git -- with from local reset Hard recover
2023-09-14 09:00:48 时间
If you've removed a commit with git reset --hard
, it's still possible to recover the commit using git reflog
to look up the commit hash.
Once we find the right commit hash, we can reset our branch back to that commit hash with git reset --hard [HASH]
NOTE! git will actually garbage collect abandoned commits (every 30 days or so - so not very often) - so you can't recover from a reset --hard
forever; which is why it's recommended to avoid --hard
if you ever want to references those changes.
git reflog
Find the commit id which you want to recover then do:
git reset --hard [AHSH-id]
相关文章
- git push到远程指定分支_gitcheckout远程分支
- git 那些事儿 —— 基于 Learn Git Branching
- git 报错Git fatal: Unknown index entry format xxxxx的错误解决方法
- 建立git服务器_git部署代码到服务器
- git 本地文件上传 github || gitee
- (四)Git——团队协作
- git checkout 命令详解
- Git 使用笔记
- Git 常用命令大全 (总结篇)
- 在idea中使用git
- 2-4. 实战Git常用操作(IDEA界面+命令)
- 【代码管理】GitHub超详细图文攻略 - Git客户端下载安装 GitHub提交修改源码工作流程 Git分支 标签 过滤 Git版本工作流
- 【Git】Git 基础命令 ( Git 版本库概念 | 创建版本库 git init | 克隆版本库 git clone )
- 【错误记录】Git 使用报错 ( error: Cannot delete branch ‘dev‘ checked out at ‘D:/Git/git-learning-course‘)
- 【错误记录】Git 使用报错 ( git: ‘switch‘ is not a git command. See ‘git --help‘. )
- 【Git】Git 分支管理 ( 解决分支合并冲突 | 创建并切换分支 git switch -c feature1 | 修改 feature1 分支并提交 | 修改 master 主版本并提交 )
- 【Git】Git 分支管理 ( 使用 git cherry-pick 命令提取提交记录应用于当前分支 | 创建新分支应用某个提交 | git cherry-pick 冲突处理 )
- Git - 记一次完整的新旧Gitlab迁移
- git添加新用户详解程序员
- 学习Linux如何使用Git代码版本管理(linux使用git)
- 版本Linux 查看 Git 版本信息的方法(linux查看git)
- 使用Git来升级你的Linux系统(git升级linux)
- Git实现Linux内核快速下载(git下载linux内核)
- 极速学习:Linux下使用Git的基础知识(linux如何使用git)