35

I was using the system version of git and then updated to the latest version using homebrew. After doing so, all the git shortcuts provided by the oh-my-zsh git plugin stopped working. I tried reinstalling oh-my-zsh but don't really know what else to do.

The only other thing I've changed is that I recently installed hub but I have not aliased it yet.

bsiddiqui
  • 1,886
  • 5
  • 25
  • 35
  • Do you mean the aliases such as `gst` (`git status`)? What does `which git` and `which ` return? – simont Jun 21 '13 at 01:36
  • Yeah all the aliases provided by the git plugin like gst, gco (git checkout), etc are broken. which git returns /usr/local/bin/git and which gst returns gst not found... other plugins, like rails, still work – bsiddiqui Jun 21 '13 at 02:22
  • What does `alias | grep git` return? Do you see the aliases listed there? – simont Jun 21 '13 at 02:29
  • No I don't. It shows the git alias' that I wrote in my .zshrc file but none of the alias' from the plugin – bsiddiqui Jun 21 '13 at 02:32
  • 2
    That sounds like either `oh-my-zsh` isn't being sourced, or the `git` section of the `oh-my-zsh` files isn't being sourced. Do you have a line similar to `source ~/.oh-my-zsh/oh-my-zsh.sh` in your `~/.zshrc`? Does your `~/.zshrc` have `plugins=(git)` in it? – simont Jun 21 '13 at 02:36
  • The file that should contain all the `git` alias' is `~/.oh-my-zsh/plugins/git/git.plugin.zsh`: [online here](https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/git/git.plugin.zsh), (assuming you haven't installed somewhere other than `$HOME`). You could also check that that file exists in your `oh-my-zsh` installation (it should, unless you removed it). – simont Jun 21 '13 at 02:41
  • 1
    Well if oh-my-zsh wasn't being sourced, I don't think the rails plugin would work. The git plugin is in the correct location. I do have a line that sources oh-my-zsh... I think something happened specifically to the git plugin when I upgraded to git using brew (from system git) because it worked before the update – bsiddiqui Jun 21 '13 at 03:44
  • you're right, even though oh-my-zsh was being sourced, the git plugin was not being sourced... would adding source ~/.oh-my-zsh/plugins/git/git.plugin.zsh be the best solution? Post as an answer so I can accept it. Thanks! – bsiddiqui Jun 21 '13 at 03:47
  • I had a different problem. I thought my zsh git autocompletion was broken. When I was trying to do `git add *.java` it said `no command found`. Finally I figured it out I was supposed to do `git add "*.java"` to add files. I'm new to `zsh`, so adding this as a comment hoping this might help someone. – Akbarsha Mar 11 '19 at 10:08
  • I found someting really weird in my `.zshrc` file, the plugins were separated by comas and then after stripping off the comas everything worked, so making sure I am always using `plugins=(git osx docker)` format did the trick! – herrera Apr 27 '19 at 10:22

2 Answers2

70

To load zsh plugins default format as specified in .zshrc is plugins=(rails git textmate ruby lighthouse). For some reason it was written in this format plugins=(git, lighthouse) separated by comma. Separating just by space and source the .zshrc after saving fixed the issue.

Zubair Alam
  • 8,739
  • 3
  • 26
  • 25
63

From the comments, the oh-my-zsh plugin containing the git aliases isn't being sourced.

To do fix this, you can either:

  1. Directly source the plugin by adding source ~/.oh-my-zsh/plugins/git/git.plugin.zsh to your ~/.zshrc,
  2. Enable the plugin the canonical way: by adding git to the plugins=(...) line in ~/.zshrc: plugins=(git osx ruby). Note: my understanding is that, if you have two lines with plugins=(), the second will overwrite the first - I think (untested) that plugins=($plugins git) allows for enabling of plugins over multiple lines.
simont
  • 68,704
  • 18
  • 117
  • 136