gcb
gcb

Reputation: 14548

git alias to rename existing command

I'm loosing too much work working on both svn and git repositories at work. And i'm not the only one: Get back the changes after accidental checkout?

I wanted to rename/overload the checkout command with an alias.

basically, checkout would just show me a diff of what i'm losing (or curse at myself, or run the sl command :D )

and then i'd have the revert to alias to do the real checkout command.

Is the first step possible? to alias something over the original command? or will checkout always trigger the checkout command? I basically want to lock me out of checkout.

Bonus points if i can change the behaviour only when git checkout <file> and not on git checkout <branch/tag/ref>

Upvotes: 2

Views: 177

Answers (1)

VonC
VonC

Reputation: 1324268

The easiest way would be to make a wrapper for the command git itself (and reference that wrapper first in the PATH environment variable)

The wrapper could check:

  • what command is run (checkout or not)
  • what parameter is used (a file or not)

Upvotes: 2

Related Questions