code

git 로그에 이동 된 파일의 기록이 표시되지 않는 이유는 무엇이며 어떻게해야합니까?

codestyles 2020. 10. 5. 07:56
반응형

git 로그에 이동 된 파일의 기록이 표시되지 않는 이유는 무엇이며 어떻게해야합니까?


git mv, used를 사용 하여 몇 개의 파일 이름을 변경하고 git stashHEAD를 빠르게 살펴본 다음 (변경하지 않고) git stash pop전체를 다시 가져 왔습니다. 내 움직임이 커밋 목록에서 사라졌기 때문에 나는 그들을 다시 썼고 git rm커밋 메시지는 git이 이름 바꾸기가 이름 바꾸기라는 것을 발견했다고 주장했습니다. 그래서 더 이상 생각하지 않았습니다.

하지만 이제 커밋 후 이동 된 파일의 기록을 가져올 수 없습니다! 다음은 문제의 커밋에 대해 git이 말하는 내용입니다.

~/projects% git log --summary
commit de6e9fa2179ae17ec35a5c368d246f19da27f93a
Author: brone
Date:   Wed Dec 8 22:37:54 2010 +0000

    Moved R_DebugUI into runtime

 delete mode 100644 test/R_DebugUI_iOS.h
 delete mode 100644 test/R_DebugUI_iOS.m
 create mode 100644 system/runtime/src/R_DebugUI_iOS.h
 create mode 100644 system/runtime/src/R_DebugUI_iOS.m

 <<snip older commits>>
 ~/projects%

이제 이동 된 파일 중 하나의 기록을 가져 오려고하므로 이전 버전을 볼 수 있지만 매우 유용한 것은 없습니다.

~/projects/system/runtime/src% git log --follow --find-copies-harder -M -C R_DebugUI_iOS.m
commit de6e9fa2179ae17ec35a5c368d246f19da27f93a
Author: brone
Date:   Wed Dec 8 22:37:54 2010 +0000

    Moved R_DebugUI into runtime
~/projects/system/runtime/src% 

( -M, -C없이 시도 --find-copies-harder했지만 아무 소용이 없습니다.)

이전 이름으로 기록을 가져올 수 있으며 이전 위치에서 삭제 된 시점에서 중지됩니다.

~/projects% git log --summary --follow --find-copies-harder -M -C -- test/R_DebugUI_iOS.m
commit de6e9fa2179ae17ec35a5c368d246f19da27f93a
Author: brone
Date:   Wed Dec 8 22:37:54 2010 +0000

    Moved R_DebugUI into runtime

 delete mode 100644 test/R_DebugUI_iOS.m

commit 32a22d53c27e260714f759ecb3d3864e38b2e87f
Author: brone
Date:   Tue Dec 7 23:52:51 2010 +0000

    Can set debug UI's alpha.

<<snip older commits>>
~/projects%

그래서 이번에는 완전히 갇혀 있지는 않지만 항상 이런 종류의 일을해야하는 것을 좋아하지는 않을 것입니다. (나는 평생에 한 번 이상 이동할 파일이 상당히 많을 것으로 예상합니다.)

내가 뭘 잘못하고 있니? 파일의 이전 복사본과 새 복사본은 98.8 % 동일합니다 (166 개 중 2 줄 변경됨). 내 이해는 git이이 경우 파일을 추적 할 수 있어야한다는 것입니다. 왜냐하면 명시 적으로 저장하는 것이 아니라 이름 바꾸기 작업을 추론하기 때문이며 파일은 동일하다고 생각할만큼 충분히 유사합니다.

이 문제를 해결하기 위해 할 수있는 일이 있습니까?


git log --follow파일 에서 시도해보십시오 . 나는 여기에서 배운다 . git에서 파일을 이동 / 이름 변경하고 기록을 유지할 수 있습니까?


Well, I do see my renames with git log -M --summary..


Answering my own question, since I have managed to assuage my concerns, even if I haven't solved my problem exactly. (git log --follow still doesn't work for me, though.)

Firstly, the --summary log for the renaming commit includes the delete line with the file's old name. So if it's easy to spot, you can find its old name and git log from there.

If it's part of some large commit, and therefore a bit harder to spot -- and this situation was one of my worries -- git blame -C can be used with the file's new name on the first post-rename revision. Presumably lines remain from the original file! -- so git should find their source, and show old file name (and a commit hash for good measure). You can then pick up the trail with git log.

So, if you have some interest in the history of the file as a unit (for whatever reason) then it seems like it can be done relatively straightforwardly. Though I get the impression git would prefer that you used it properly.


git log --follow ./path/to/file

I believe this is what you're looking for.

참고URL : https://stackoverflow.com/questions/4393527/why-might-git-log-not-show-history-for-a-moved-file-and-what-can-i-do-about-it

반응형