Live data from Hacker News

A safer git checkout

cirw.in

1–10 of 20 posts

Re: A safer git checkout

#4
Perhaps I'm missing something, but in years of development using git as our scm, I have never used checkout -f. I've used reset --hard HEAD here and there. Is there any difference in their use?

Also, are there a lot of developers who work for hours without committing? I've only found myself in a situation where I could possibly lose hours of work a few times and each time this happens I realize I was treading thin ice.

Lastly, and maybe this is also just me, I keep my repos in Dropbox. Github is our main repo store, but I've got an extra level of protection, especially since Dropbox allows you to rollback file changes.

Re: A safer git checkout

#5
post #4

Perhaps I'm missing something, but in years of development using git as our scm, I have never used checkout -f. I've used reset --hard HEAD here and there. Is there any difference in their use? Also, are there a lot of developers who work for hours without committing? I've only found myself in a situation where I could possibly lose hours of work a few times and each time this happens I realize I was treading thin ic…

I've worked with developers that went days without committing... it was maddening.

Re: A safer git checkout

#6
post #4

Perhaps I'm missing something, but in years of development using git as our scm, I have never used checkout -f. I've used reset --hard HEAD here and there. Is there any difference in their use? Also, are there a lot of developers who work for hours without committing? I've only found myself in a situation where I could possibly lose hours of work a few times and each time this happens I realize I was treading thin ic…

> Also, are there a lot of developers who work for hours without committing?

I manage maybe an hour at a max, and then have to make extensive use of commit -p to tease apart all the changes I've made.

Re: A safer git checkout

#7
post #5
post #4

Perhaps I'm missing something, but in years of development using git as our scm, I have never used checkout -f. I've used reset --hard HEAD here and there. Is there any difference in their use? Also, are there a lot of developers who work for hours without committing? I've only found myself in a situation where I could possibly lose hours of work a few times and each time this happens I realize I was treading thin ic…

I've worked with developers that went days without committing... it was maddening.

Can we all work on this? Somehow nobody seems to treat writing crappy commits (messages like "work since Tuesday" or "it works now") like they would writing crappy code. Version control is fundamental to our job.

Re: A safer git checkout

#10
I've been using Git for a couple years now, and I don't think I've ever lost any work.

Even if you do `git reset --hard HEAD~5`, "throwing away" your last few commits, they aren't actually discarded yet. You can do `git reflog` to see them and then `git checkout -b some_commit_hash` to recover one to a branch, or `git reset --hard some_commit-hash` to set this branch back to that point.

Only if those commits stay orphaned for a while (a week or two?) will Git truly discard them.

Post reply on HN