LoginSignup
37
13

More than 3 years have passed since last update.

git configコマンドを実行しようとしたらxcrun: errorになった

Last updated at Posted at 2020-01-01

エラー内容

githubのUserNameを変更したので、ローカルのUsernameも変更しようとしたら下記のエラーが出た。

$ git config --global user.name 'NewUserName'
xcrun: error: active developer path ("/Users/User/Downloads/Xcode.app/Contents/Developer") does not exist
Use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, or use `xcode-select --install` to install the standalone command line developer tools.
See `man xcode-select` for more details.

エラー文をそのままコピペして調べると、xcode-select --installしなさいと出たので実行。

$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

またエラーに。
再びググると、XCodeのCommand Line Toolsのパスを修正する必要があることがわかった。

パス修正手順

  1. $ xcode-select -p

「/Library/Developer/CommandLineTools」と表示されれば正常。
「/Applications/Xcode.app/Contents/Developer」と表示されたらパスがおかしいので2へ。

2.sudo xcode-select -switch /Library/Developer/CommandLineTools を実行
3. 再度xcode-select -pを実行。
4. 「/Library/Developer/CommandLineTools」と出力されることを確認

上記対応後、無事git configできるようになった。

ついでに

GitのUserNameを変更した場合のローカルの修正

UserNameの修正

$ git config --global user.name 'newUserName'

$ git config --global -lで確認。

リポジトリURLの修正

$ cd ローカルリポジトリ
$ git remote -v

# 変更前
origin  git@github.com:oldName/repository_name.git (fetch)
origin  git@github.com:oldName/repository_name.git (push)

$ git remote set-url origin git@github.com:new_name/repository_name.git
$ git remote -v

# 変更後
origin  git@github.com:newName/repository_name.git (fetch)
origin  git@github.com:oldName/repository_name.git (push)

pushの方がoldNameになっていたため下記を実行

$ git remote set-url --push origin git@github.com:new_name/repository_name.git
$ git remote -v

# 変更後
origin  git@github.com:newName/repository_name.git (fetch)
origin  git@github.com:newName/repository_name.git (push)

無事どっちも修正された。

参考

https://techracho.bpsinc.jp/hachi8833/2016_09_09/25454
https://dangerous-animal141.hatenablog.com/entry/2014/05/05/000000

37
13
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
37
13