Git:如何在不同的提交中区分两个不同的文件? [英] Git: How to diff two different files in different commits?

查看:87
本文介绍了Git:如何在不同的提交中区分两个不同的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储库,自上次提取以来,许多文件已从.html重命名为.php,并在许多提交中进行了进一步编辑。使用 git diff 显示已删除的所有 html 内容和所有 php 内容已添加。是否有一种巧妙的方法让 git diff 检测到重命名(类似于 git log --follow 那样),或者直接比较不同提交之间的不同文件名(类似于 Git:如何在不同的分支中区分两个不同的文件?,但要提交)?

I have a repository where a number of files have been renamed from .html to .php and further edited in a number of commits since my last pull. Using git diff to shows all the html contents removed and all the php content added. Is there a neat way to have git diff detect the renames (something like git log --follow does), or directly compare different filenames across different commits (something like the solution in Git: How to diff two different files in different branches? , but for commits)?

推荐答案

总是比较2个不同提交中的2个文件:

You can always compare 2 files in 2 different commits:

git diff commit1:file1_path commit2:file2_path

这篇关于Git:如何在不同的提交中区分两个不同的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆