5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

porcelainオプションでgit statusの出力をmachine-readableにする

Posted at

以下のような見慣れた出力を、他の処理の入力として使いたいとする。

$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   first
        new file:   second

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   first

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        third

porcelainオプションを使うとファイルごとの出力になる。

$ git status --porcelain
MM first
A  second
?? third

フォーマットの詳細は

$ man git-status

補足

porcelainとは磁器のことで、gitのコマンドのうち比較的ユーザーフレンドリーな部分をporcelainと呼ぶ。

ただし--porcelainオプションの機能は、porcelainコマンドを実行することというよりはmachine-readableな出力をさせることのようである。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?