·터미널 명령어

git ls-files

git

쓰는 꼴

git ls-files [-o|-m|-i] [--exclude-standard]

디스크가 아니라 색인에 든 경로를 나열합니다 — 스크립트로 추적 파일을 훑을 때 믿을 수 있는 목록이고, -i는 혼자 쓰지 못해 -c나 -o와 --exclude-standard를 함께 적어야 합니다.

자주 쓰는 옵션

옵션
-cfiles in the index; the default
-mtracked files modified on disk
-dtracked files that are missing
-ofiles git does not track
-iignored files; must come with -o or -c and --exclude-standard
--exclude-standardapply .gitignore and friends
-sshow mode and object id of each entry
-zseparate paths with NUL for xargs -0

예시

git ls-files

every tracked path, straight from the index

git ls-files -o --exclude-standard

untracked files only, respecting .gitignore

git ls-files -i -c --exclude-standard

tracked files that .gitignore says should be ignored

되돌리는 방법이 여럿이라 헷갈립니다 — 가리키는 곳을 옮기는 것과 새 커밋을 얹는 것은 다릅니다.

읽는 방법

  • 대괄호 [ ]는 넣어도 되고 안 넣어도 되는 자리입니다.
  • 점 셋 …은 여러 개를 이어 쓸 수 있다는 뜻입니다.
  • 옵션은 대소문자를 가립니다 — -r과 -R이 다른 명령도 있습니다.

자주 묻는 것

Q. git ls-files은 무엇을 하나요?

디스크가 아니라 색인에 든 경로를 나열합니다 — 스크립트로 추적 파일을 훑을 때 믿을 수 있는 목록이고, -i는 혼자 쓰지 못해 -c나 -o와 --exclude-standard를 함께 적어야 합니다.

Q. 어떻게 치나요?

git ls-files [-o|-m|-i] [--exclude-standard] — 대괄호는 생략할 수 있는 자리입니다.

Q. 옵션은 몇 개나 자주 쓰나요?

여기 정리한 것은 8개입니다. 전체 목록은 man git에 있습니다. 이 명령은 git 갈래입니다.

같이 보는 명령

man 페이지: man git-ls-files