您的位置:首页 > 其它

使用Git进行本地提交后,未上传提交,却不小心删除了本地提交或提交所在分支,怎么办?????

2014-06-12 09:11 411 查看
使用Git进行本地提交后,未上传提交,却不小心删除了本地提交或提交所在分支,怎么办?????

不要紧!!!!

可以使用git reflog命令来帮助恢复删除的本地提交!

运行以下命令你就知道怎么用了!


1. git stash 清空工作区和暂存区

2. git pull 同步服务器代码

3. git commit –allow-empty -m “this is a test” 进行一次空提交

4. git reset HEAD^ –hard 删除刚才的空提交

5. git reflog 查看各分支的提交记录

70cf5fe HEAD@{0}: reset: moving to HEAD^
28d447f HEAD@{1}: commit: this is a test
70cf5fe HEAD@{2}: pull: Fast-forward

6. git reset 28d447f –hard 恢复到commit号为28d447f 的提交,亦可使用HEAD@{1}

7. git log

看this is a test 提交是不是回来了!!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐