development

git log --since는 어떻게 계산됩니까?

big-blog 2020. 11. 8. 10:31
반응형

git log --since는 어떻게 계산됩니까?


몇 개의 커밋 만있는 간단한 테스트 저장소가 있고 날짜 및 시간 필터링 된 로그를보고 싶습니다.

$ git log --author = "automatix"--since = "2013-01-30"--pretty-테스트
커밋 ea0719bef142659fa561c9d040b2120012ed0184
날짜 : 2013 년 1 월 31 일 목요일 02:03:12 +0100

커밋 ab4a8387bc4d9bdb4f67212df77eb1fc3d8b6304
날짜 : 2013 년 1 월 31 일 목요일 01:59:11 +0100

커밋 a0b027beba2cd03571bb9475b9db9542f8efe990
날짜 : 2013 년 1 월 31 일 목요일 01:50:38 +0100

커밋 add77c8fe2ba9254c11b98e14facede3420dc51c
날짜 : 2013 년 1 월 31 일 목요일 01:48:34 +0100

커밋 e6e323c05d37c74fcabeb9186b95c0d49b862e6f
날짜 : 2013 년 1 월 31 일 목요일 01:46:27 +0100

커밋 8c286391e54d3fc1e210950b1320fd6f013a8f84
날짜 : 2013 년 1 월 31 일 목요일 01:41:27 +0100

커밋 9c880595e57f717383796fa2940f41f0f42f7e2a
날짜 : 2013 년 1 월 31 일 목요일 01:38:17 +0100

커밋 a95527f36a533e1ecba1aadceea31a9dcbe1a8db
날짜 : 2013 년 1 월 31 일 목요일 01:30:00 +0100

제 선택된는 커밋 a95527f36a533e1ecba1aadceea31a9dcbe1a8db에서 2013-01-30 01:30:00. 8 개의 커밋이 선택되었습니다.

$ git log --author = "automatix"--since = "2013-01-30"--format = oneline-테스트 | 화장실
      8 34 498

확인. 이제 다음과 같이 선택합니다 2013-01-31.

$ git log --author = "automatix"--since = "2013-01-31"--format = oneline-테스트 | 화장실
      0 0 0

뭐? 좋습니다. 이것은 since규칙이 시작일 의 커밋을 제외 한다는 것을 의미 합니다. 권리?

그러나 계속합시다.

$ git log --author = "automatix"--since = "2013-01-31 01:30:00"--pretty-테스트
커밋 ea0719bef142659fa561c9d040b2120012ed0184
날짜 : 2013 년 1 월 31 일 목요일 02:03:12 +0100

커밋 ab4a8387bc4d9bdb4f67212df77eb1fc3d8b6304
날짜 : 2013 년 1 월 31 일 목요일 01:59:11 +0100

커밋 a0b027beba2cd03571bb9475b9db9542f8efe990
날짜 : 2013 년 1 월 31 일 목요일 01:50:38 +0100

커밋 add77c8fe2ba9254c11b98e14facede3420dc51c
날짜 : 2013 년 1 월 31 일 목요일 01:48:34 +0100

커밋 e6e323c05d37c74fcabeb9186b95c0d49b862e6f
날짜 : 2013 년 1 월 31 일 목요일 01:46:27 +0100

커밋 8c286391e54d3fc1e210950b1320fd6f013a8f84
날짜 : 2013 년 1 월 31 일 목요일 01:41:27 +0100

커밋 9c880595e57f717383796fa2940f41f0f42f7e2a
날짜 : 2013 년 1 월 31 일 목요일 01:38:17 +0100

커밋 a95527f36a533e1ecba1aadceea31a9dcbe1a8db
날짜 : 2013 년 1 월 31 일 목요일 01:30:00 +0100
$ git log --author = "automatix"--since = "2013-01-31 01:30:00"--format = oneline-테스트 | 화장실
      8 34 498

이제 시작 시간도 작성할 때 시작 시간의 커밋이 포함 됩니다.

I don't understand the logic. Can anybody explain, why it works so strange?

Thanks


In case it helps someone else who lands here like I did, after a bit of researching I found out that using ISO8601 format also works:

git log --since="2014-02-12T16:36:00-07:00"

This will give you precision down to the second. Note: you can also use:

git log --after="2014-02-12T16:36:00-07:00"
git log --before="2014-02-12T16:36:00-07:00"
git log --since="1 month ago"
git log --since="2 weeks 3 days 2 hours 30 minutes 59 seconds ago"

etc.

Of course, this doesn't "explain why it works so strange." However, it certainly solved the problem for me.


EDIT:

After a bit more research, I found out "why it works so strangely":
It turns out that when you don't specify a date format, git log defaults to either the author's timezone or commit dates, meaning for consistent behavior, it's useful to explicitly declare your date format with something like:

git log --date=local

Lastly, when you don't specify a time, it defaults to your local time when you ran the command.

Long story short, being specific should solve the problem:

git log --date=local --after="2014-02-12T16:36:00-07:00"

Also, you can set the default date format permanently with the following command:

git config log.date local

you can use any one of these values: (relative|local|default|iso|rfc|short|raw)

참고URL : https://stackoverflow.com/questions/14618022/how-does-git-log-since-count

반응형