Git으로 두 날짜 사이에 발생한 모든 커밋 사이의 차이점을 어떻게 알 수 있습니까?
아니면 두 날짜 사이에 발생한 모든 커밋입니까? SVN에서는 다음과 같은 작업을 수행 할 수 있습니다
svn diff -r{date}:{date}
그것을하기 위해! 나는 이것과 동등한 Git을 찾을 수없는 것 같습니다.
특히 나는 그 날 커밋 된 모든 코드와 누가 이메일을 매일 보내는 스크립트를 작성하려고합니다.
당신은 사용할 수 있습니다 git whatchanged --since="1 day ago" -p
또한 --until
논쟁 이 필요합니다 .
이전 제안에는 몇 가지 단점이 있습니다. 기본적으로 나는와 동등한 것을 찾고있었습니다 cvs diff -D"1 day ago" -D"2010-02-29 11:11"
. 점점 더 많은 정보를 수집하면서 해결책을 찾았습니다.
내가 시도한 것 :
git whatchanged --since="1 day ago" -p
에서 여기그러나 하나의 파일에 여러 개의 커밋이 있더라도 각 커밋마다 차이가 있습니다. "날짜"가 git에서 약간 느슨한 개념이라는 것을 알고 있습니다.이 작업을 수행 할 방법이 있어야한다고 생각했습니다.
git diff 'master@{1 day ago}..master
경고를 표시warning: Log for 'master' only goes back to Tue, 16 Mar 2010 14:17:32 +0100.
하고 모든 diff를 표시하지는 않습니다.git format-patch --since=yesterday --stdout
나를 위해 아무것도주지 않습니다.revs=$(git log --pretty="format:%H" --since="1 day ago");git diff $(echo "$revs"|tail -n1) $(echo "$revs"|head -n1)
어떻게 든 작동하지만 복잡해 보이고 현재 분기로 제한되지 않습니다.
드디어:
git-cvsserver는 "cvs diff -D"를 지원하지 않습니다 (어딘가에 문서화되어 있지 않음).
"날짜"는 git에서 약간 느슨한 개념입니다. 커밋은 누군가가 실제로 커밋을 리포지토리로 가져 오기 / 커밋하기 전에 과거에 어느 정도 시간이 걸릴 수있는 커밋 날짜를 갖습니다. 또한 커밋은 새로운 커밋의 상단에 있도록 리베이스되고 업데이트 될 수 있습니다.
커밋은 또한 커밋이 어떤 방식 으로든 리베이스되거나 수정되면 업데이트되는 커밋 날짜를 갖습니다. 이러한 커밋은 연대순으로 정렬 될 가능성이 높지만 여전히 컴퓨터에 올바른 시간이 설정되어있는 커미터의 자비에 달려 있기 때문에 수정되지 않은 커밋은 원격 저장소의 기능 분기에 무기한으로 배치 될 수 있습니다. 중앙 저장소의 마스터 브랜치로 병합됩니다.
아마도 귀하의 목적에 가장 유용한 것은 해당 특정 리포지토리의 참조 날짜입니다. 분기 별 참조 로그가 활성화 된 경우 (참조 git config core.logAllRefUpdates
) ref@{date}
구문을 사용하여 분기가 특정 시간에 있었던 위치를 참조 할 수 있습니다 .
예 :
git log -p master@{2009-07-01}..master@{now}
다음과 같은 '퍼지'설명을 사용할 수도 있습니다.
git log -p "master@{1 month ago}..master@{yesterday}"
이 명령은 작성자 및 커밋 날짜에 따라 실제로 얼마나 '오래된'지에 관계없이 리포지토리의 지정된 분기에 '나타난'커밋을 모두 표시합니다.
분기 별 reflog는 리포지토리에 따라 다르므로 복제본에서 log 명령을 실행 중이고 한 달 동안 가져 오지 않은 경우 마지막 달의 모든 변경 사항을 한 번에 가져옵니다. 지난 달의 모든 변경 사항이 일정 @{1 hour ago}..@{now}
범위에 나타납니다 . 사람들이 추진하는 '중앙'저장소에서 log 명령을 실행할 수 있다면 원하는 것을 수행 할 수 있습니다.
git diff --stat @{2013-11-01}..@{2013-11-30}
또는
git diff --stat @{2.weeks.ago}..@{last.week}
혹시
$ git format-patch --committer=<who> --since=yesterday --stdout
(---- stdout '의 유무에 관계없이) 원하는 것입니까?
일반적인 해결책은 다음을 사용하는 것입니다.
git rev-list -n1 --first-parent --until=<a date string> <a ref>
--first-parent가 없으면 나중에 병합 a ref
되었지만 병합되지 않은 지점에서 커밋을 얻을 수 있습니다 a date string
.
여기에 사용하는 대안입니다 --children
및 grep
대신 -n1
:
mlm_git_ref_as_of() {
# # Examples #
#
# Show all commits between two dates:
#
# git log $(mlm_git_ref_as_of '2012-05-21 09:00:00-0400')..$(mlm_git_ref_as_of '2012-05-21 17:00:00-0400')
#
# Show diffs of all commits between two dates:
#
# git diff $(mlm_git_ref_as_of '2012-05-21 09:00:00-0400')..$(mlm_git_ref_as_of '2012-05-21 17:00:00-0400')
local as_of="$1"
local ref="${2:-HEAD}"
# Get the most recent commit (--children, grep -v ' ') that was on
# the given branch ($ref, --first-parent) as of a given date
# ($as_of)
git rev-list --children --first-parent --until="$as_of" "$ref" | grep -v ' '
}
I wasn't familiar with git whatchanged
before reading this Q&A, but it gives very different results for me, so I'm not sure what it's doing.
Another simple way that you can get a diff of all changes since a certain date is to simply find the first commit X
that occured on or after that date, then use
git diff X
This has the advantage that it doesn't depend on reflog entries in a fresh clone, unlike the
git diff <reference>@{n}..
git log <reference>@{n}..
solutions in
- https://stackoverflow.com/a/20171168/456814
- https://stackoverflow.com/a/1161712/456814
- https://stackoverflow.com/a/2455374/456814
This is more of a funny answer, because there is likely a better way. This will show all commit hashes for today.
git log --pretty="format:%H %ai" | grep `date +"%Y-%m-%d"` | awk {'print $1'}`
;·)
You can also use git-format-patch to prepare patches (diffs) and send them through email.
Use options [since] or [revision range] to specify commits range.
I'll throw in the way I do it: git log
for a date gives you commit hashes for the current branch. Then I just use something like git diff 8fgdfg8..565k4l5
which gives me proper difference aggregated by files. Hope this helps, not tested much though
In order to watch files changes from date to date on your branch ,use the following formula:
- checkout your branch.
- pull and update changes from remote repository
- watch diff files from date to date range
example:
git checkout <branch>
git pull
git diff --stat @{fromDate}..@a{toDate}
Pay attention the dates are on YYYY-MM-DD format:
git diff --stat @{2019-08-20}..@a{2019-08-21}
If you'd like to observe changes on specific file in specific time range (watch diff in code), just navigate the current file:
example:
git diff @{2019-01-01}..@{2019-01-02} ~/dev/myApp/package.json
'programing tip' 카테고리의 다른 글
“System.IO.Compression”네임 스페이스에서“ZipFile”클래스를 찾지 못했습니다 (0) | 2020.07.30 |
---|---|
“오류 : 선택한 JDK에서 Java VM 실행 파일을 확인할 수 없습니다”의 이유는 무엇입니까? (0) | 2020.07.30 |
안전하지 않은 JavaScript가 URL로 프레임에 액세스하려고합니다. (0) | 2020.07.29 |
ipython 내에서 Python 스크립트 실행 (0) | 2020.07.29 |
Axios와 Fetch의 차이점은 무엇입니까? (0) | 2020.07.29 |