1
0

More than 1 year has passed since last update.

githubのURLが本当に存在するかシェルスクリプトから確認する

Last updated at Posted at 2021-12-29

githubのURLが本当に存在するかシェルスクリプトから確認する際の備忘メモ

git ls-remoteを使えばOK、
結果は直前に実行したコマンドの結果である$?の値から判断可能

成功する場合
$ git ls-remote https://github.com/mozillazg/pypy
69c2f6b75bbd409ccddea9d88e58d1410c0b9859    HEAD
f8a2f37e91b7871322243a8df432f5fdc2b3d4e6    refs/heads/0.6.1/tip
...
$ echo $?
0
失敗する場合
$ git ls-remote https://github.com/mozillazg/pypyaaaaaaaaaaaaaaaa
remote: Repository not found.
fatal: repository 'https://github.com/mozillazg/pypyaaaaaaaaaaaaaaaa/' not found
$ echo $?
128

ブランチの存在も確認したい場合は以下を参照

git ls-remoteでブランチの存在も確認したい

参考

1
0
0

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
1
0