git archive
git
쓰는 꼴
git archive --format=tar.gz -o <file> <tree-ish>커밋 한 시점의 파일들을 tar나 zip으로 내보냅니다 — .git과 추적되지 않은 파일이 들어가지 않아 폴더를 그대로 압축하는 것보다 깨끗한 배포 묶음이 됩니다.
자주 쓰는 옵션
| 옵션 | 뜻 |
|---|---|
| --format=<fmt> | tar, zip or tar.gz |
| -o <file> | write to a file; the format is guessed from the name |
| --prefix=<dir>/ | put everything under one folder inside the archive |
| --add-file=<file> | include an untracked file as well |
| --remote=<repo> | let the server build it |
| -l | list the formats this build supports |
예시
git archive --format=tar.gz -o app-1.2.0.tar.gz v1.2.0a release tarball of exactly that tag
git archive --prefix=app/ -o app.zip HEADa zip whose contents sit inside app/
git archive -o src.zip HEAD -- srconly the src directory
되돌리는 방법이 여럿이라 헷갈립니다 — 가리키는 곳을 옮기는 것과 새 커밋을 얹는 것은 다릅니다.
읽는 방법
- 대괄호 [ ]는 넣어도 되고 안 넣어도 되는 자리입니다.
- 점 셋 …은 여러 개를 이어 쓸 수 있다는 뜻입니다.
- 옵션은 대소문자를 가립니다 — -r과 -R이 다른 명령도 있습니다.
자주 묻는 것
Q. git archive은 무엇을 하나요?
커밋 한 시점의 파일들을 tar나 zip으로 내보냅니다 — .git과 추적되지 않은 파일이 들어가지 않아 폴더를 그대로 압축하는 것보다 깨끗한 배포 묶음이 됩니다.
Q. 어떻게 치나요?
git archive --format=tar.gz -o <file> <tree-ish> — 대괄호는 생략할 수 있는 자리입니다.
Q. 옵션은 몇 개나 자주 쓰나요?
여기 정리한 것은 6개입니다. 전체 목록은 man git에 있습니다. 이 명령은 git 갈래입니다.
같이 보는 명령
man 페이지: man git-archive