git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: test2.js
Untracked files:
(use "git add <file>..." to include in what will be committed)
test1.js
git add <파일/디렉터리>
# 확장자가 .a인 파일 무시
*.a
# 위 라인에서 확장자가 .a인 파일은 무시하게 했지만 lib.a는 무시하지 않음
!lib.a
# 현재 디렉터리에 있는 TODO파일은 무시하고 subdir/TODO처럼 하위디렉터리에 있는 파일은 무시하지 않음
/TODO
# build/ 디렉터리에 있는 모든 파일은 무시
build/
# doc/notes.txt 파일은 무시하고 doc/server/arch.txt 파일은 무시하지 않음
doc/*.txt
# doc 디렉터리 아래의 모든 .pdf 파일을 무시
doc/**/*.pdf
git diff
git diff --staged
git diff --cached
git commit
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Your branch is up-to-date with 'origin/master'.
#
# Changes to be committed:
# new file: README
# modified: CONTRIBUTING.md
#
~
~
~
".git/COMMIT_EDITMSG" 9L, 283C
git commit -v
git commit -m <메시지>
git commit -a -m <메시지>
git rm <파일>
Staging Area에서 삭제한 후에 커밋
파일명 대신에 패턴을 사용하면 여러 개의 파일이나 디렉터리 한 번에 삭제 가능
디렉터리와 git에서 파일을 삭제하는 순서
git rm -f <파일>
git rm --cached <파일>
git mv <변경 전 파일> <변경 후 파일>
mv <변경 전 파일> <변경 후 파일>
git rm <변경 전 파일>
git add <변경 후 파일>