git 상태가 준비된 파일 만 표시하도록하는 방법 –name-only에 대한 git

준비된 파일 이름 목록 만 얻고 싶습니다. 나는의 해당 플래그를 찾을 수 없습니다 --name-only에 대한 git status명령. 좋은 대안은 무엇입니까?

파일 목록은 php -l(PHP lint 구문 검사기) 로 파이프됩니다 .

솔루션 : 완전한 명령

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



답변

사용 git diff --name-only( --cached스테이징 된 파일을 가져 오기 위해 사용 )


답변

받아 들여진 대답은 어떤 종류의 변경 사항 이 있었 는지 알려주지 않습니다 .

예, 구문 검사기가 아니라 준비되지 않은 파일로 가득 찬 저장소를 가진 평범한 사람이고 준비된 파일에 어떤 일이 발생하는지 여전히 알고 싶다면 다른 명령이 있습니다.

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_file되며 renamed_to.

다음은 짧은 형식 출력에 대한 설명입니다. https://git-scm.com/docs/git-status#_short_format


답변

@ 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 '^??'"

다른 사람에게 유용 할 수 있습니다. 따라서 답변 스택에 추가하십시오.


답변

코드 변경 사항이있는 스테이징 된 파일보기

git diff --staged

또는 –staged와 동의어 인 –cached 사용

git diff --cached

또는 코드 변경없이 파일 이름 만보기

git diff --staged --name-only

git-diff 매뉴얼


답변