본문 바로가기
utils/git and github

[Git] log: commit history 살펴보기

by ds31x 2023. 12. 31.

log : commit history 살펴보기

git log 는 git 으로 관리되는 프로젝트의 commit history 를 보여주는 명령어.

누가 언제 어떻게 프로젝트에 변경이 이루어졌는지, 브랜치간의 관계, commit id 등을 확인할 수 있음.


기본 사용

git log
  • 현재의 branch의 commit history를 시간의 역순으로 출력해줌.
  • 각 commit 에는 author, date, commit message, commit id (SHA1 hash value)를 보여줌.

2024.05.21 - [분류 전체보기] - [CE] Hash Algorithm

 

[CE] Hash Algorithm

Hash 는 임의의 크기를 가진 데이터를 고정된 크기의 (고유한) 데이터로 변환하는 방법 임.이 변환 과정은 Hash Algorithm에 의해 명확하게 정의됨.Hash Algorithm을 통해 생성된 해시 값(Hash, Hash Value)은특

ds31x.tistory.com

 


git log <branch_name>
  • <branch_name> 을 보여줌.

주요 Options

  • --branches :
    • 모든 브랜치의 commit history를 출력
  • --oneline :
    • 각 commit 들을 한 line으로 출력.
  • -n <int> :
    • commit history 에서 출력할 commit 의 수를 지정
    • 숫자로 지정.
  • --stat :
    • 각 commit에서 변경된 파일과 추가 및 삭제된 line 수를 출력.
    • statistics 를 출력.
  • --graph :
    • branches 의 merge 등의 관계를 ascii graph 로 출력.

특정 범위의 commit history 출력 또는 branch 간의 차이를 출력

git log <기준_branch>..<대상_branch>
  • <기준_branch><대상_branch> 의 차이점을 출력해줌.
  • 기준_branch 에는 없고, 대상_branch 에는 있는 commit 을 출력.

git log <시작_commit>..<끝_commit>
  • 시작_commit 부터 끝_commit 사이의 commit history 출력 (현재 branch에서)
  • git log HEAD~4..HEAD : 현재 branch의 최신 commit 의 4번째 전 commit (HEAD~4) 이후부터 최신 commit (HEAD) 까지의 commit history 출력.

 

범위를 나타내는 .. 를 사용할 때,
시작하는 위치 이후 부터 (exclusive)
끝나는 위치까지임 (inclusive)
(시작 commit id등은 exclusive임)

같이 읽어보면 좋은 자료들

[Git] Git Summary (작성중) (tistory.com)

 

[Git] Git Summary (작성중)

git이란2024.05.20 - [utils/git and github] - Git : 소개 git 설치 후 해줘야 하는 작업들[Git] git 설치 후 우선 해줘야 하는 작업들 (tistory.com)local repository 초기화2024.05.20 - [utils/git and github] - [Git] init : local rep

ds31x.tistory.com

 

728x90