git add -p は git add –patch の省略形

エンジニア研修で「git add -p を使うといいよ」と話していて、ふと「-p って何の略なんだろう?」とイマサラ疑問に思ったので調べてみました。

Git

部分的に git add できるので –partial の略なのかと思っていたのですが、help を確認してみたら –patch の省略形ということが書いてありました。

$ git add -h    
usage: git add [options] [--] <pathspec>...
 
    -n, --dry-run         dry run
    -v, --verbose         be verbose
 
    -i, --interactive     interactive picking
    -p, --patch           select hunks interactively
    -e, --edit            edit current diff and apply
    -f, --force           allow adding otherwise ignored files
    -u, --update          update tracked files
    -N, --intent-to-add   record only the fact that the path will be added later
    -A, --all             add changes from all tracked and untracked files
    --ignore-removal      ignore paths removed in the working tree (same as --no-all)
    --refresh             don't add, only refresh the index
    --ignore-errors       just skip files which cannot be added because of errors
    --ignore-missing      check if - even missing - files are

ショートオプション名は、オプションの正式名称を理解すると覚えやすいと思ってるので、今後も疑問に感じたらすぐに調べるようにします。