5
1

More than 1 year has passed since last update.

【Git】リポジトリ名を取得する方法

Posted at

取得方法

以下のコマンドを実行することでリポジトリ名を取得できます。

$ basename -s .git `git remote get-url origin`
sample-repo
  • git remote get-url origin
    リポジトリのURLを取得する。
    https://github.com/UserName/repo-name.gitのように取得できる。

  • basename
    git remote get-url originの実行結果からrepo-name.git部分のみ取得する。

  • -s .git
    repo-name.gitから.gitを除外する。

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