Gitjk – command to undo what you just did in git
github.com
github.com
git jk git <command>
commands are executables of the form 'git-<command>' in specific directory: $ git --exec-path
/usr/local/Cellar/git/1.9.0/libexec/git-core
$ ls $(git --exec-path) | head
git
git-add
git-add--interactive
git-am
git-annotate
git-apply
git-archimport
git-archive
git-bisect
git-bisect--helper
In git's earlier years, it was just a set of git-<command> commands in $PATH, until the master git command was created (to 'rule them all' if you will).git will actually pick up anything in $PATH of the form 'git-<command>' and allow you to run it as 'git <command>'. The downside of this, is that commands of the form:
git <command> --help
are intercepted by git and converted to: man git-<command>
So your command cannot process the --help option itself when called like this (or it used to be this way a couple of years ago).Edit: Another downside, is that some 'smart' command-line completion settings either have a hard-coded list of 'git <command>' commands, or look for said commands in the value returned by 'git --exec-path'. So you can't tab-complete git-<command> commands that you just drop into $PATH (at least not out of the box).
The git fixup page comes in quite handy. https://sethrobertson.github.io/GitFixUm/fixup.html
When I run 'rm -r' on my machine it warns me about every file in the .git directory.
It really depends on how much coffee and sleep I've had. Thanks for the kind words.
But as someone else here mentioned, you really want to understand the reflog in git. Everyone screws up at some point or another, and it's much easier to work through things when you can rely on the reflog to act as a safety net and an anchor of sanity.
function jk
history | head -n+10 | tail -r | gitjk_cmd
end
Maybe git full undo via automatic snapshotting (branch/stash)? It's fine unless you hit a perf wall on huge repos.Edit: now recommends git reset unless you did "git add ." or something like that.