项目在本地写了很久,没有 commit 过,今天打开的时候从很早之前的一个 commit 版本打开了,咋恢复

2021-08-01 20:47:53 +08:00
 theSong

今天脑抽,webstorm 打开的时候清了下启动项目那里的缓存,发现代码变成了很久之前的一个版本,git history 是很久之前的了。 能恢复吗?编辑器本身的缓存打开,而不是 git 的某一个版本打开,咋操作?

5589 次点击
所在节点    程序员
51 条回复
Zhuzhuchenyan
2021-08-01 20:58:26 +08:00
看一下 webstorm 的 local history,或许还能救

没有 stash 的话基本没办法了
raysonx
2021-08-01 21:22:18 +08:00
git reflog 找找之前的 commit 记录
raysonx
2021-08-01 21:22:42 +08:00
如果没有 commit 那就没了
hullopanda
2021-08-01 21:26:03 +08:00
这每天不 commit 是啥好习惯啊
尝试恢复 webstorm 的数据,从 windows 磁盘层面去恢复。
tonytonychopper
2021-08-01 21:39:53 +08:00
每天 commit 才是好习惯
liuzhaowei55
2021-08-01 21:44:19 +08:00
应该随手 commit 就像随手 Ctrl + S 一样
yitingbai
2021-08-01 21:49:02 +08:00
一楼说的对, webstorm 自身有文件历史记录, 可以保留一段时间, 可以找回来
enchilada2020
2021-08-01 21:56:18 +08:00
@liuzhaowei55 如果写了一半没写完的呢 也要 commit 吗?有点强迫症 每次都想把一个完整的写完 一切都干干净净了再 commit 觉得写了一半像草稿的 commit 之后有记录 心里总有疙瘩。。
yitingbai
2021-08-01 21:58:10 +08:00
@enchilada2020 提交记录写清楚不就行了, 什么临时保存, **功能尚未完成, 这种强迫症要不得
Rache1
2021-08-01 22:03:08 +08:00
Local History 也不是万能的 😂

[Local History]( https://www.jetbrains.com/help/webstorm/local-history.html)

> Note that Local History is not a replacement for a proper version control for long-term versioning. Local History is cleared when you install a new version of WebStorm. It also has a [retention period]( https://www.jetbrains.com/help/webstorm/local-history.html#local-history-retention) and maximum size, so revisions are not guaranteed to persist.
512357301
2021-08-01 22:04:58 +08:00
@enchilada2020 commit 的目的就是记录你的思路,开源嘛,让别人也能知道你的代码变动过程。
一次性完整写完再 commit 大可不必,一次性完整写完我觉得那应该叫发版或者大版本,这里面肯定应该有无数个小版本来支撑的
raysonx
2021-08-01 22:09:17 +08:00
@enchilada2020 完整写完后可以把之前的 squash 成一个 commit 再提交
ClericPy
2021-08-01 22:22:57 +08:00
wip commit 了解一下...
ClericPy
2021-08-01 22:23:22 +08:00
看错了... 已经覆盖了的话只能指望 IDE 自带的撤回了, 我撤回过...
pengtdyd
2021-08-01 22:39:20 +08:00
项目在本地写了很久,没有 commit 过。就这句话我觉的你还真是个人才
WenhaoWu
2021-08-01 23:02:46 +08:00
commit --amend 了解一下
mercury233
2021-08-01 23:03:45 +08:00
我也不喜欢每天 commit 但我会 add
forgottencoast
2021-08-01 23:15:20 +08:00
@enchilada2020
搞一个开发分支,弄好了,合并成一个 commit 也可以解决有强迫症的问题。
正常是每次完成一个小改动就 commit 。
中途的临时保存可以用 stash,这个不是 commit 。
CEBBCAT
2021-08-02 00:00:25 +08:00
听起来有点不合理,是不是打开错项目了?不然的话我怀疑是你没有描述清楚,Intellij 这些都是有自动保存的,比如窗口失焦,更别说关闭程序了。

清理缓存不可能把代码都清理掉的
theSong
2021-08-02 00:02:00 +08:00
@Zhuzhuchenyan 找着了,还好 stash 了

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/793036

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX