News for hackers. Stuff that matters.
Re:A Git catastrophe cleaned up by guard-of-terra on Wednesday December 21, 2016 @08:10AM (#13228782)
Two fun things about git: It is deterministic, and it doesn't delete anything (readily).

This means you can't really have a catastrophe.

Just git reflog your way out.

Re:A Git catastrophe cleaned up by rplst8 on Wednesday December 21, 2016 @09:04AM (#13229130)
This is the right answer. I think for whatever reason, software programmers are afraid to learn how git works. They'll spend countless hours learning how their other tools work - but not the one that keeps and protects changes to their work. It's maddening. The worst part is - it's really not that difficult to go into the .git directory and look at how the files are structured and learn it. Once you do, a lot of using git becomes second nature.
Re:A Git catastrophe cleaned up by kwe on Wednesday December 21, 2016 @09:21AM (#13229253)
This is the video that I keep recommending to new people who want to know how it works on a technical level. I've always had amazing/euphoric feedback to that recommendation.

https://www.youtube.com/watch?v=ZDR433b0HJY

Re:A Git catastrophe cleaned up by rplst8 on Wednesday December 21, 2016 @09:55AM (#13229555)
Cool. For me it is this video. https://www.youtube.com/watch?v=MYP56QJpDr4

I notice they are from the same publisher.

Re:A Git catastrophe cleaned up by tomp on Wednesday December 21, 2016 @08:12AM (#13228792)
That's a bit of an overstatement. You can't have a catastrophe with stuff already committed (but it's very easy to delete in-progress work).
Re:A Git catastrophe cleaned up by duiker101 on Wednesday December 21, 2016 @08:17AM (#13228819)
If you are committing so rarely that you can have a CATASTROPHE with your in-progress work, maybe you should try breaking the work in smaller parts and committing more often
Re:A Git catastrophe cleaned up by lmm on Wednesday December 21, 2016 @10:18AM (#13229742)
Unfortunately git's staging area concept encourages you to do exactly the opposite of this.
Re:A Git catastrophe cleaned up by reitanqild on Wednesday December 21, 2016 @10:35AM (#13229866)
I almost only use it to cherry-pick and then immediately commit?
Re:A Git catastrophe cleaned up by lmm on Thursday December 22, 2016 @05:51AM (#13236392)
Right, all the good use cases involve not actually using it - if you're immediately committing then it would be better if it just became a commit.
Re:A Git catastrophe cleaned up by reitanqild on Thursday December 22, 2016 @07:38AM (#13236849)
I meant: I cherrypick from my changes and commit bugfixes and drive-by update of comments separately.

My bad. I shouldn't have used the word cherrypick there.

Re:A Git catastrophe cleaned up by guard-of-terra on Wednesday December 21, 2016 @08:14AM (#13228802)
Only if you never commit and then do checkout -f / reset --hard. Why would you be doing that?

Otherwise it's still in reflog. Anything you ever commited is just there.

Re:A Git catastrophe cleaned up by mnarayan01 on Wednesday December 21, 2016 @08:42AM (#13228967)
Unreachable references will be pruned after 30 days (by default) if/when git-gc gets run (which will occasionally happen automatically by default). Not saying it's a problem, just note that they're not actually there forever.
Re:A Git catastrophe cleaned up by lomnakkus on Wednesday December 21, 2016 @08:54AM (#13229066)
For reflog it's 90 days. (So anything referenced by the reflog will be retained for that long.)
Re:A Git catastrophe cleaned up by mnarayan01 on Wednesday December 21, 2016 @12:32PM (#13230895)
AFAICT, for unreachable entries (e.g. as generated by `git commit --amend`) the default is 30 days as defined by `gc.reflogExpireUnreachable`.
Re:A Git catastrophe cleaned up by gergoerdi on Friday December 23, 2016 @02:12AM (#13243383)
No, because those commits are still reachable from the reflog.
Re:A Git catastrophe cleaned up by gpderetta on Wednesday December 21, 2016 @06:38PM (#13233602)
well unless you haven't pushed in a while and you rm -rf your home directory. Of course that has never happened to me.

On a completely unrelated topic, extundelete is a great piece of software.

Re:A Git catastrophe cleaned up by CJefferson on Wednesday December 21, 2016 @12:41PM (#13230982)
I've had occasional data-loss from git.

The problem is when you realise someone badly rebased, or forced a push, a while ago and now you have to try to find where the stuff was lost.

Re:A Git catastrophe cleaned up by qwertyuiop924 on Wednesday December 21, 2016 @08:27AM (#13228872)
the reflog is GCed, IIRC. So if you wait long enough, and commit long enough, that history will be gone.
Re:A Git catastrophe cleaned up by lomnakkus on Wednesday December 21, 2016 @08:53AM (#13229059)
The reflog GC is time-based -- it defaults to retaining entries 90 days.