News for hackers. Stuff that matters.
Re:Helping a Million Developers Exit Vim by logicallee on Tuesday May 23, 2017 @01:53PM (#14403444)
hey Linus, undo last 1 git command (as though it had never been entered):

  git undo 1
thanks.
Re:Helping a Million Developers Exit Vim by falcolas on Tuesday May 23, 2017 @03:00PM (#14404138)
Only works for commits, but it's a very useful alias I've picked up.

    [alias]
        undo = reset HEAD~1 --mixed
Re:Helping a Million Developers Exit Vim by postozoan on Tuesday May 23, 2017 @04:50PM (#14405201)
How about git uncommit? Undo suggests it might work for other actions like pushing
Re:Helping a Million Developers Exit Vim by emodendroket on Tuesday May 23, 2017 @02:02PM (#14403555)
I'll bet between the reflog and aliases you could do that.
Re:Helping a Million Developers Exit Vim by kccqzy on Tuesday May 23, 2017 @02:16PM (#14403707)
How would you undo "git reflog expire"? How would you undo "git push origin -f"?
Re:Helping a Million Developers Exit Vim by hdhzy on Tuesday May 23, 2017 @02:37PM (#14403921)
> How would you undo "git push origin -f"?

Remote reflog contains this info (if enabled).

Of course not all commands would be reversible, especially not plumbing.

Re:Helping a Million Developers Exit Vim by majewsky on Tuesday May 23, 2017 @02:35PM (#14403901)
> git reflog expire

Is there a valid reason to do this in the first place?

> git push origin -f

No standard way to undo that. Only do it if you must, and you absolutely do what's going to happen. Always do a "got remote update" immediately before the force-push and double-check that the remote branch points to what you expect.

As a general rule, "--force" is short for "you better be prepared to deal with the consequences".

Re:Helping a Million Developers Exit Vim by emodendroket on Tuesday May 23, 2017 @04:52PM (#14405214)
Well let me put the question back to you: can changes to git provide undo for literally every command?
Re:Helping a Million Developers Exit Vim by Ajedi32 on Tuesday May 23, 2017 @03:52PM (#14404647)
Wouldn't work with commands like `git reset --hard` or `git checkout --force` though. Those commands delete uncommitted changes permanently.
Re:Helping a Million Developers Exit Vim by logicallee on Tuesday May 23, 2017 @02:23PM (#14403771)
I'm requesting the exact syntax I just wrote.

EDIT: the replies to this don't get how feature requests work. yes, I could write this basic feature myself. thanks.

Re:Helping a Million Developers Exit Vim by gknoy on Tuesday May 23, 2017 @02:55PM (#14404092)
You can make a bash script named `git-undo` , put it in your path (I use ~/bin):

    #! /bin/bash
    git reset HEAD~1 && git checkout .
Re:Helping a Million Developers Exit Vim by emodendroket on Tuesday May 23, 2017 @03:01PM (#14404158)
You can assign git aliases that execute shell commands by prefixing with an exclamation mark.
Re:Helping a Million Developers Exit Vim by emodendroket on Tuesday May 23, 2017 @02:35PM (#14403902)
So write a script and assign an alias.
Re:Helping a Million Developers Exit Vim by oblio on Tuesday May 23, 2017 @06:17PM (#14405873)
You're missing his point. Defaults matter. A huge majority of users (80%?) never change the defaults, often for good reasons.

A minor usability investment on the part of 1-2 git developers would prevent thousands of hours wasted by newbies and perpetual intermediates (https://blog.codinghorror.com/defending-perpetual-intermedia...).

Re:Helping a Million Developers Exit Vim by emodendroket on Tuesday May 23, 2017 @07:52PM (#14406493)
A feature like undo is never going to be implemented as a core thing because there are too many instances where it's not clear what it should do.