98

ステージングされたファイル名のみのリストを取得したいと思います。コマンド--name-onlyの同等のフラグが見つかりません。git status良い代替手段は何ですか?

ファイルリストはphp -l(PHP lint 構文チェッカー) にパイプされます。

解決策: 完全なコマンド

git diff --name-only --cached | xargs -l php -l
4

7 に答える 7

145

使用git diff --name-only--cachedステージングされたファイルを取得するために)

于 2010-12-24T07:59:03.190 に答える
21

受け入れられた回答では、どのような変更があったかはわかりません。

はい、構文チェッカーではなく、ステージングされていないファイルでいっぱいのリポジトリを持つ普通の人で、ステージングされたファイルがどうなるか知りたい場合は、別のコマンドがあります。

git status --short | grep '^[MARCD]'

次のような結果になります。

M  dir/modified_file
A  dir/new_file
R  dir/renamed -> dir/renamed_to
C  dir/copied_file
D  dir/deleted_file

明らかに、このファイルはステージングされ、git commit:
deleted_fileが削除され、
new_file追加され
renamed_filerenamed_to.

短い形式の出力の説明は次のとおりです: https://git-scm.com/docs/git-status#_short_format

于 2018-06-06T13:54:31.597 に答える
6

@ coffman21の回答に触発されて、次のエイリアスを設定しました.zshrc

alias gst="git status"
alias gst-staged="git status --short | grep '^\w.'"
alias gst-unstaged="git status  --short | grep '^\W.'"
alias gst-unstaged-tracked="git status  --short | grep '^\s.'"
alias gst-untracked="git status --short | grep '^??'"

また

alias gst="git status"
alias staged="git status --short | grep '^\w.'"
alias unstaged="git status  --short | grep '^\W.'"
alias unstaged-tracked="git status  --short | grep '^\s.'"
alias untracked="git status --short | grep '^??'"

それは他の誰かに役立つかもしれません。したがって、それを回答のスタックに追加します。

于 2020-09-09T21:02:59.963 に答える