#TIL #git 코드가 삭제된 커밋 찾기

$ git log -SText

Text 문자열이 삭제된 커밋을 찾는다.

-S<string> Look for differences that change the number of occurrences of the specified string (i.e. addition/deletion) in a file. Intended for the scripter’s use.

It is useful when you’re looking for an exact block of code (like a struct), and want to know the history of that block since it first came into being: use the feature iteratively to feed the interesting block in the preimage back into -S, and keep going until you get the very first version of the block.

사실 삭제만 찾는 게 아니라 추가와 삭제를 모두 찾는다.

정규식을 사용하려면 -G 옵션을 사용. 대소문자 무시하고 찾으려면 -i 옵션을 사용하면 된다.


Feedback plz <3 @ohyecloudy, ohyecloudy@gmail.com

A Random Post