星期三, 1月 14, 2015

Sublime Text Plugin "AutoBackups"

唉... 杯具了... 沒有把 Git 弄熟,只會基本的 clone, pull, commit, push和一點 branch... 每次寫程式都感覺要寫到一個程度才 commit + push,沒有養成經常在 local commit 的習慣。結果因為手殘誤在某個 bower_components package 裡,下了 git reset --hard HEAD^ 把兩天的成果都給輕乾淨了...

至於為什麼會這麼搞,說來話長。總之痛過一次就學乖了... 不過,為了避免將來有其他耍笨的時候,還是裝了 Sublime Text 的自動備份 plugin「AutoBackups」。他可以在每次存檔的時候幫忙建立備份,備份資料的資料夾會以日期命名(yyyy-MM-DD),檔案名稱則是會自動加上時間(filename_HHmmss),所以可以回溯到每次存檔的階段。如果怕檔案累積量太大,也可以設定保留的時間(比方30天後自動刪除)。初步用起來感覺還不錯,推薦給各位試試。

2 意見:

Unknown 提到...

I don't think git reset --hard HEAD^ will kill everything. Here is a tutorial for you.
http://gitready.com/advanced/2009/01/17/restoring-lost-commits.html

Long ago I read some articles talked about it's important to do 'commit' very often, even the change is very small. And make sure to develop in your dev branch, or even create some branches (production, test... ex http://nvie.com/posts/a-successful-git-branching-model/) . Use 'tag' to checkout to your particular tag's version by create a branch (ex.http://git-scm.com/book/en/v2/Git-Basics-Tagging). BTW, I remember I saw an article that said kernel developers all use tags to search and patch kernel.

Anyway, just some info for you. My git experience is not superior to yours. We're just keep learning as damn much as we can swallow.

Unknown 提到...

Oh, one more thing. I use gitlab.com to store my private and working code and dot files. If shit happened, I can just clone back. It's free for both personal and business. You can give it a try.