2020年12月23日星期三

Have git show in command line changes that occured for a single file in a large commit without changing HEAD

Let's say I have a few commits in a large repository with many branches.

projectname:some/branch* λ git log --oneline -n4 --graph  *   742b5fd1a (HEAD -> some/branch) Added many bugs  | * 16963a72a (TAG: Release_9, upstream/version_B) Release Test fix  | * 5643f6a7c (tag: RELEASE_8) Fixed bug  | * e31f00146 (tag: RELEASE_7) Fixed race condition  

I want to see the changes that occurred to core/library_foo/foo.cpp for RELEASE_8 (5643f6a7c), without checking out RELEASE_8. I can't checkout because the size of the repository is very large, so checking out takes an extremely long time (many minutes). This commit also has a few hundred files changed, hence wanting to limit it to a single file.

I am expecting to do the following, but neither of which work (they just show the git commit message without a textual diff of the file, or give me errors). This file DID change for that commit, based on viewing the commit in sublime merge, and gitk.

git show 5643f6a7c core/library_foo/foo.cpp  git show 5643f6a7c:core/library_foo/foo.cpp  git show 5643f6a7c -- core/library_foo/foo.cpp    git log 5643f6a7c core/library_foo/foo.cpp    git log 5643f6a7c:core/library_foo/foo.cpp  git log 5643f6a7c -- core/library_foo/foo.cpp  

I had to adjust the file paths, commit hashes, commit messages, tag names, and branch names, due to this example being done on a private repository. This is for a pretty recent git (2.29.0).

https://stackoverflow.com/questions/65431408/have-git-show-in-command-line-changes-that-occured-for-a-single-file-in-a-large December 24, 2020 at 05:54AM

没有评论:

发表评论