Open wada811 opened 5 years ago
Git のブランチ名のリストが欲しい。
git branch | tr -d '*' | tr -d ' '
git branch --format=<format>
単純に git branch すると以下のようになる。
git branch
* develop master
そのため tr で * と半角スペースを除去する。
tr
*
git branch --format="%(refname:short)"
develop master
-a オプションを付けたときの結果が異なる。
-a
git branch -a | tr -d '*' | tr -d ' '
develop master remotes/origin/master
git branch -a --format="%(refname:short)
develop master origin/master
Why
Git のブランチ名のリストが欲しい。
What
git branch | tr -d '*' | tr -d ' '
git branch --format=<format>
How
1.
git branch | tr -d '*' | tr -d ' '
単純に
git branch
すると以下のようになる。そのため
tr
で*
と半角スペースを除去する。2.
git branch --format="%(refname:short)"
1 と 2 の違い
-a
オプションを付けたときの結果が異なる。1.
git branch -a | tr -d '*' | tr -d ' '
2.
git branch -a --format="%(refname:short)
Ref