본문 바로가기

Git

[Git] git commit 파일 내용 검색 (feat. git grep / log -G)

반응형

https://git-scm.com/docs/git-grep

 

Git - git-grep Documentation

Look for specified patterns in the tracked files in the work tree, blobs registered in the index file, or blobs in given tree objects. Patterns are lists of one or more search expressions separated by newline characters. An empty string as search expressio

git-scm.com

 

파일 검색하기 (현재 파일 기준) git grep

git grep [검색 내용]

 

커밋로그 검색하기 git log --grep

커밋로그에서 원하는 로그를 검색하고자 할 때는 git log 명령어 --grep 옵션을 사용하면 커밋로그에서 원하는 메시지가 들어간 커밋을 검색할 수 있다.

git log --grep [검색내용]

 

파일 내용으로 커밋로그 검색하기 git log -G

git log 에 -G옵션을 주고 텍스트를 써서 파일 내용이 있었던 커밋로그를 찾을 수 있다.

git log -G 옵션은 델타를 기준으로 검색을 한다.

위처럼 변경사항에  websocket이라는 단어가 들어간 커밋을 조회할 수 있다. 그래서 찾고자 하는 단어가 제거된 경우 언제 지워졌는지 찾을 때 유용하게 사용할 수 있다.

git log -G[찾을 텍스트]
git log --oneline -G/test

f3498c6 [UPDATE] LOCATION TIME
211e18c [COMMIT] STANDARD ADD

 

참고

https://books.goalkicker.com/GitBook/

https://blog.outsider.ne.kr/849

 

반응형

'Git' 카테고리의 다른 글

[Git] github push error: RPC failed; result=22, HTTP code = 408  (0) 2023.06.08
[Git] old mode new mode  (0) 2021.09.27
[Git] remote  (0) 2021.08.10
[Git] git 기초 참고 사이트  (0) 2021.04.06
git 최초 설정  (0) 2021.02.25