-1

I did this (was trying to set an 'self' alias with -v):

 git() { if [[ $1 == "commit" ]]; then command git commit -v; else command git "$@"; fi; }
  git() { if [[ $1 == "commit" ]]; then command git commit -v; else command git "$@"; fi; }
  git() { git commit }; )
  git() { git commit; }
  git() { git (); }
  git() { git(); }
  git() { git() }

and now all git commmands hang - no error but no return prompt.

I've uninstalled and installed git but it hasn't helped.

How can I reset git command back to the default?

I've tried mv .gitconfig .gitconfig_old but it didn't help.

  • 4
    So do you or do you not have a problem with git? If you ran git() { git(); }, then you defined git as a function that does nothing but call itself. Undefine it (unset -f git) or redefine it to something sensible first. – Gilles 'SO- stop being evil' Sep 24 '12 at 00:21

1 Answers1

3

You sound really confused.

All those function definitions you ran were in the shell. If you ran them directly from the command line, then they only affect the current running shell environment. So if you had just closed the terminal and started a new one, the definitions would have been lost, and everything would be back to normal. Or you could have unset the definition with unset -f, as described in the comment.

This is why re-installing git has no bearing on your problem.

Renaming your .gitconfig won't make any difference either. You didn't make the changes in your .gitconfig, so why would it?

If you had followed the advice in your previous question, and set up an alias using git's aliasing method instead, then moving your .gitconfig would indeed have had an effect, and would have effectively removed your alias (along with all the rest of your configuration).

Incidently, all this confusion with the base command being overridden is the main reason git doesn't allow this type of name remapping under its own aliasing system. To quote the git-config manpage:

"To avoid confusion and troubles with script usage, aliases that hide existing git commands are ignored."