Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
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 Sep 24 '12 at 0:21

1 Answer 1

up vote 3 down vote accepted

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."

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.