프로그래밍/Git

[Git] 2. Commit (feat. log, diff)

Beginner:) 2023. 5. 27.
320x100

git commit --help

git commit --help

 

git stage area -> commit

(commit시 -m은 --message의 약자 필수 옵션)

git add . 
git commit -m "[메시지(로그)]"

 

git add & git commit 동시에

 

git commit -am "[메시지(로그)]"

 

메시지가 없는 commit

git commit --allow-empty-message -am "[메시지(로그)]"

 

수정 이력 없이 commit 

(push를 하고 싶으면 강제 푸시를 해야 하니 git pull 또는 이력을 보고 또 보고 push 할 것)

git commit --ammand --no-edit
git push -f

 

 

git commit 기록 출력(시간 내림차순)

 

git log

 

git log 출력 개수 지정

git log [-number]

 

git log diff 출력

git log -p

 

stage area와 working directory를 비교

git diff

로그를 보면

1. printf("Hello 2_git_commit stage area");로 수정하고 git add를 함.

2. printf("Hello 2_git_commit working directory");로 수정

3. git diff

 

git commit과 working directory 비교

git diff HEAD[or commit number]

로그에는 안 찍혀있는데 마지막 commit이 printf("Hello 2_git_commit -empty message"); 로 되어있음.

 

반응형

'프로그래밍 > Git' 카테고리의 다른 글

[Git] 4. branch(2)  (0) 2023.06.05
[Git] 3. branch(1)  (0) 2023.05.31
[Git] 계정 자동 로그인(feat. VSCode)  (0) 2023.05.29
[Git] 1. Git stage (feat. tracked 상태란)  (0) 2023.05.24
Git Permission denied (publickey) 에러 해결  (0) 2023.02.25

댓글