36

Since I upgrade my OSX to El Capitan when I want to update Oh My Zsh upgrade_oh_my_zsh I got the following error:

Upgrading Oh My Zsh
fatal: Not a git repository (or any of the parent directories): .git
There was an error updating. Try again later?

I never used git before, searching this fatal error on the internet they advice to do git init in the /.oh-my-zsh folder. After running this command a new fatal error occur when I try to run upgrade_oh_my_zsh again.

fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists. 

I don't know if it has anything to do with with it but when I open the terminal (iTerm2) I also got this notification:

/Users/peter/.zshrc:1: command not found: Path

Anyone has experience with this or knows a solution for my problem?

Travis
  • 13,311
  • 4
  • 26
  • 40
Peter
  • 1,240
  • 2
  • 13
  • 22

11 Answers11

52

Looks like your git repo was removed from oh-my-zsh? You can re-add the remote and update to the latest version of Zsh by running:

cd ~/.oh-my-zsh
git init # you've already done this step, so you can skip
git remote add origin https://github.com/ohmyzsh/ohmyzsh.git
git fetch
git reset --hard origin/master

After that, restart your terminal instance and you should be good to go.

enter image description here

Travis
  • 13,311
  • 4
  • 26
  • 40
18

I just encountered that message. In my case (on a Mac) it just so happens that I just installed Xcode, and that git stopped working until I accepted its terms and conditions. Just in case...

n__o
  • 1,620
  • 15
  • 18
  • 1
    The same happened to me. When I ran `omz update`, I was instructed to run `sudo xcodebuild -license`, as I had recently installed Xcode. Running the command fixed the issue. – Jussi Virtanen Aug 19 '22 at 07:57
  • I already had xcode but I updated my macOS and it reset it - https://stackoverflow.com/a/53089103/4654175 – Shubham Sharma Nov 01 '22 at 02:38
16

The above solution didn't work for me. The problem in my case was that I have an alias

alias gpucb="git pull origin $(git branch --show-current)"

As soon as I commented it the error was gone. I need a fix for this. Also, the weird part is that the error is encountered only in the second git command.

Aashutosh Rathi
  • 763
  • 2
  • 13
  • 28
8

For me, the root cause of the error was the upgrade to macOS Ventura. Doing xcode-select --install and restarting the terminal fixed the issue.

astro_bear
  • 103
  • 1
  • 4
2

When I had this issue, I started by seeing what happened to my git

$git --version

Then it prompts to accept the new agreement on XCODE. So I ran

$sudo xcodebuild -license

After that, it will install the updates, then open XCODE.

Then all will be fine.

Akshay
  • 926
  • 9
  • 21
1

In my case macOS Ventura 13.x. Download and installed Command Line Tools for Xcode 14.1 it's solved my issue

Hossain Misho
  • 121
  • 1
  • 2
1

By trying the accepted solution, I got this error:

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

However, running this (and restarting the terminal) helped me:

$ xcode-select --install

see also this answer

Joël Brigate
  • 237
  • 2
  • 13
0

rm -rf "$ZSH"

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

kirill-petrov
  • 71
  • 1
  • 3
0

I had exactly same error message and it was because of Xcode update. I had to start Xcode and accept some license & feature changes. Afterwards, the message has gone.

I believe the message is result of multiple processes. Not only git problems but also for Xcode.

It's better to check Xcode if you face with this error.

Ahmet
  • 126
  • 2
0

This is due Xcode upgrade. Open Xcode.app in your MAC, accept new terms and conditions and then it will install some upgrades and error will disappear from oh-my-zsh.

e4e6d4d5
  • 1
  • 2
0

In my case, I needed to do a system update. The issue was resolved after the update.

daktari
  • 91
  • 1
  • 8