파일 커밋
새 파일을 추가하고 우리가 방금 만든 저장소 아래에 등록하겠습니다.
다음 텍스트 콘텐츠를 사용하여 해당 디렉터리에 sample.txt라는 파일을 만듭니다.
Anyone can learn Git with this tutorial and Backlog
우리는 git status 명령 을 사용하여 "tutorial" 디렉터리의 상태를 확인할 수 있습니다.
$ git status
On branch main
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
sample.txt
nothing added to commit but untracked files present (use "git add" to track)
응답에서 sample.txt가 현재 추적되고 있지 않음을 알 수 있습니다. 추적하려면 먼저 인덱스에 sample.txt를 추가해야 합니다.
인덱스에 추가하려는 파일 뒤에 git add 명령 을 사용합니다. 여러 파일을 추가하려면 공백으로 구분하십시오. 그런 다음 sample.txt가 인덱스에 성공적으로 추가되었는지 확인합니다.
개별 파일 이름 대신 .을 지정하여 현재 디렉터리의 모든 파일을 인덱스에 추가할 수 있습니다.
$ git add sample.txt
$ git status
On branch main
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: sample.txt
이제 sample.txt"가 인덱스에 추가되었으므로 파일 커밋을 진행할 수 있습니다. git commit 명령 을 사용하고 다시 상태를 확인합니다.
$ git commit -m "first commit"
[main (root-commit) 13fc237] first commit
1 file changed, 1 insertion(+)
create mode 100644 sample.txt
$ git status
On branch main
nothing to commit, working tree clean
명령의 응답은 더 이상 커밋할 새로운 변경 사항이 없다고 알려줍니다.
git log 명령을 사용하여 저장소의 히스토리 로그에서 새로 추가된 커밋을 볼 수 있습니다.
$ git log
commit ac56e474afbbe1eab9ebce5b3ab48ac4c73ad60e
Author: username
Date: Thu Jul 12 18:00:21 2022 +0900
first commit
다음으로 팀과 저장소를 공유할 준비가 되었습니다