当文件夹结构发生变化时比较提交之间的文件
Compare file between commits when folder structure has changed
问题:
当文件夹结构在 commit_hash_1
和 commit_hash_2
之间发生变化时,如何 git diff
特定文件?
我知道的:
我可以 git diff
两次提交之间的文件:
git diff commit_hash_1 commit_hash_2 folder/file.ext
尝试的解决方案:
1. 我猜是这样的:
git diff commit_hash_1:/folder/file.ext commit_hash_2:/new_folder/file.ext
但这行不通;它给了我:
fatal: Path '/new_folder/file.ext' does not exist in 'commit_hash_2'
2. 所以另一个选项是:
git diff commit_hash_1 commit_hash_2 new_folder/file.ext
但这会开始 commit_hash_2
file.ext
和 /dev/null
之间的比较。
尝试的解决方案几乎是正确的,但那些开始的斜杠是错误的。尝试:
git diff commit_hash_1:folder/file.ext commit_hash_2:new_folder/file.ext
感谢@dlsso 让我走上正轨。
问题:
当文件夹结构在 commit_hash_1
和 commit_hash_2
之间发生变化时,如何 git diff
特定文件?
我知道的:
我可以 git diff
两次提交之间的文件:
git diff commit_hash_1 commit_hash_2 folder/file.ext
尝试的解决方案:
1. 我猜是这样的:
git diff commit_hash_1:/folder/file.ext commit_hash_2:/new_folder/file.ext
但这行不通;它给了我:
fatal: Path '/new_folder/file.ext' does not exist in 'commit_hash_2'
2. 所以另一个选项是:
git diff commit_hash_1 commit_hash_2 new_folder/file.ext
但这会开始 commit_hash_2
file.ext
和 /dev/null
之间的比较。
尝试的解决方案几乎是正确的,但那些开始的斜杠是错误的。尝试:
git diff commit_hash_1:folder/file.ext commit_hash_2:new_folder/file.ext
感谢@dlsso 让我走上正轨。