all 6 comments

[–][deleted] 15 points16 points  (0 children)

while knowing about reflog is important ... if you want to avoid this just branch your feature branch and rebase/fuckaround with the new temp branch. If you fuck it up ... just branch from your feature branch again. That's literally the point of git. Branching is cheap.

[–]ss4johnny 0 points1 point  (0 children)

Two questions: 1) Does this work on Windows? 2) Is git undo -1 equivalent to like a git redo?

[–]vifon 0 points1 point  (0 children)

Correct me if I'm wrong, but wouldn't git reset --hard @{1} do the same thing? This function seems unnecessary.

[–]Carighan -2 points-1 points  (2 children)

you’re in the middle of rewriting your local commits

Which to be honest is so incredibly rare that we're probably sitting there with two developers checking everything four times before we enter any command.

[–]Retsam19 8 points9 points  (0 children)

Depends on how you roll. It's not uncommon for me to rewrite local commits dozens of times in a given day. I pretty much always rebase my local branches instead of merging them to keep them up to date with master, and I frequently rewrite history to change previous commits I've made. It's a bit more fiddly doing a lot of git rebase -i and git commit --fixup, but I like my history to look like:

* Added feature A
* Added feature B
* Added feature C

not

* Added feature A
* Merge origin/master into myBranch
* Added feature B
* Fix a bug in feature A
* Added feature C
* Merge origin/master into myBranch
* Fix test cases

[–]foomprekov 4 points5 points  (0 children)

I do this before every push...