コマンドを雰囲気で使うのをやめたい

2021/02/06

  • Mac

と思って、自分用のメモを。

開発中に git checkout の代わりとなる git restore/switch がリリースされた()ことをふと思い出してヘルプを見たところ、「この記号なんだっけ...(汗)」とまた忘れていて、いい加減毎回調べるのやめたいと思ったため。
※厳密に言うと、まだ実験的機能

ヘルプを見てみる

今回きっかけになった git switch を例に、ヘルプを見てみます。
ヘルプはターミナルか manual page で確認できます。

$ git switch --help
...
...

NAME
       git-switch - Switch branches

SYNOPSIS
       git switch [<options>] [--no-guess] <branch>
       git switch [<options>] --detach [<start-point>]
       git switch [<options>] (-c|-C) <new-branch> [<start-point>]
       git switch [<options>] --orphan <new-branch>

DESCRIPTION
       Switch to a specified branch...
...
...

長いので割愛しますが、 SYNOPSIS を見れば大体 OK だと思います。

SYNOPSIS
       git switch [<options>] [--no-guess] <branch>
       git switch [<options>] --detach [<start-point>]
       git switch [<options>] (-c|-C) <new-branch> [<start-point>]
       git switch [<options>] --orphan <new-branch>
記号 内容
<> 必須
[] オプション
| | で区切られた中のどれか一つ

とりあえず上記記号が全て入っている 3 つ目を例に、コマンド打ってみるとこんな感じ。

# git switch [<options>] (-c|-C) <new-branch> [<start-point>]

# 現在のブランチから hoge ブランチを作成
$ git switch -c hoge

# main ブランチから hoge ブランチを作成
$ git switch -c fuga main

終わり

今後はもう大丈夫なはず。

ちなみにこの見方はドキュメント共有なので、応用はききます(多分)。
例えば MDN の Array.prototype.some() を例に見てみると、

arr.some(callback(element[, index[, array]])[, thisArg])

必須なのは element 部分だけになりますね。

const array = [1, 2, 3, 4, 5];
const even = (element) => element % 2 === 0;

console.log(array.some(even));

あんなに辛かった W3c の仕様書も、フィルタ効果 – SVG 1.1 (第2版) を例にみても...わかる!

enable-background
値: accumulate | new [ <x> <y> <width> <height> ] | inherit
...

「accumulate か new か inherit をいれてね。
もし new 使うならオプションとして x, y, width, height を指定することができるよ。」

多分こんな感じ。

  • HNポチポチ
  • 仕事Web サイトやサービスを作ってます。
  • 好きな物・こと猫・ゲーム・アニメ・コーヒー
  • このサイトについて主に開発用のメモブログですが、特に限定せず様々な事を呟きます。
  • その他私ポチポチは、Amazon.co.jpを宣伝しリンクすることによってサイトが紹介料を獲得できる手段を提供することを目的に設定されたアフィリエイトプログラムである、Amazonアソシエイト・プログラムの参加者です。
    良心に従い商品レビューをしますが、感想などは参考程度に見て頂ければと思います。

© 2020 ぽちぽち
Illust(C)masayo asano