7

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

 3 years ago
source link: https://www.v2ex.com/t/793036
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  程序员

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

  theSong · 6 小时 20 分钟前 · 1035 次点击

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

27 条回复    2021-08-02 00:55:41 +08:00

Zhuzhuchenyan

Zhuzhuchenyan   6 小时 10 分钟前

看一下 webstorm 的 local history,或许还能救

没有 stash 的话基本没办法了

raysonx

raysonx   5 小时 46 分钟前 via iPhone

git reflog 找找之前的 commit 记录

raysonx

raysonx   5 小时 46 分钟前 via iPhone

如果没有 commit 那就没了

hullopanda

hullopanda   5 小时 42 分钟前

这每天不 commit 是啥好习惯啊
尝试恢复 webstorm 的数据,从 windows 磁盘层面去恢复。

tonytonychopper

tonytonychopper   5 小时 28 分钟前 via iPhone

每天 commit 才是好习惯

liuzhaowei55

liuzhaowei55   5 小时 24 分钟前 via Android

应该随手 commit 就像随手 Ctrl + S 一样

yitingbai

yitingbai   5 小时 19 分钟前

一楼说的对, webstorm 自身有文件历史记录, 可以保留一段时间, 可以找回来

enchilada2020

enchilada2020   5 小时 12 分钟前 via Android

@liuzhaowei55 如果写了一半没写完的呢 也要 commit 吗?有点强迫症 每次都想把一个完整的写完 一切都干干净净了再 commit 觉得写了一半像草稿的 commit 之后有记录 心里总有疙瘩。。

yitingbai

yitingbai   5 小时 10 分钟前

@enchilada2020 提交记录写清楚不就行了, 什么临时保存, **功能尚未完成, 这种强迫症要不得

Rache1

Rache1   5 小时 5 分钟前

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

512357301   5 小时 3 分钟前 via Android

@enchilada2020 commit 的目的就是记录你的思路,开源嘛,让别人也能知道你的代码变动过程。
一次性完整写完再 commit 大可不必,一次性完整写完我觉得那应该叫发版或者大版本,这里面肯定应该有无数个小版本来支撑的

raysonx

raysonx   4 小时 59 分钟前 via iPad   ❤️ 1

@enchilada2020 完整写完后可以把之前的 squash 成一个 commit 再提交

ClericPy

ClericPy   4 小时 45 分钟前

wip commit 了解一下...

ClericPy

ClericPy   4 小时 45 分钟前

看错了... 已经覆盖了的话只能指望 IDE 自带的撤回了, 我撤回过...

pengtdyd

pengtdyd   4 小时 29 分钟前

项目在本地写了很久,没有 commit 过。就这句话我觉的你还真是个人才

WenhaoWu

WenhaoWu   4 小时 6 分钟前 via Android

commit --amend 了解一下

mercury233

mercury233   4 小时 5 分钟前

我也不喜欢每天 commit 但我会 add

forgottencoast

forgottencoast   3 小时 53 分钟前   ❤️ 1

@enchilada2020
搞一个开发分支,弄好了,合并成一个 commit 也可以解决有强迫症的问题。
正常是每次完成一个小改动就 commit 。
中途的临时保存可以用 stash,这个不是 commit 。

CEBBCAT

CEBBCAT   3 小时 8 分钟前

听起来有点不合理,是不是打开错项目了?不然的话我怀疑是你没有描述清楚,Intellij 这些都是有自动保存的,比如窗口失焦,更别说关闭程序了。

清理缓存不可能把代码都清理掉的

theSong

theSong   3 小时 6 分钟前

@Zhuzhuchenyan 找着了,还好 stash 了

theSong

theSong   3 小时 5 分钟前

@pengtdyd 我错了。。。

theSong

theSong   3 小时 3 分钟前

@CEBBCAT 我重新打开了另一个项目,说我这俩项目是同一个,不能同一窗口打开,然后我就同一窗口打开了。。。

theSong

theSong   3 小时 2 分钟前

@Rache1 还好是当天的,而且只损失了 nodemodules 里,重新 install 了就好了

abcysn

abcysn   2 小时 54 分钟前 via iPhone   ❤️ 1

@enchilada2020 每天提交,最后 rebase 一下把中间的提交干掉

tonytonychopper

tonytonychopper   2 小时 45 分钟前 via iPhone

@enchilada2020 这其实就涉及到功能的拆解问题了

limbo0

limbo0   2 小时 13 分钟前

最后的机会是开 timemachine, 惨痛的经理

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK