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

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

问题描述

我在不同分支中有两个不同的文件。
如何在一个命令中区分它们?

类似于

 #git diff branch1 / foo.txt branch2 / foo-another.txt 

我可以检查出另一个文件,区别它并恢复,但这是相当脏的解决方案。

> git diff branch1:full / path / to / foo.txt branch2:full / path / to / foo-another.txt

你也可以使用相对路径:

$ g $ diff branch1:./ relative / path / to / foo .txt branch2:./ relative / path / to / foo-another.txt


I have two different files in different branches. How can I diff them in one command?

Something like

# git diff branch1/foo.txt branch2/foo-another.txt

I could check out the other file, diff it and restore, but that's quite dirty solution.

解决方案

git diff branch1:full/path/to/foo.txt branch2:full/path/to/foo-another.txt

You can also use relative paths:

git diff branch1:./relative/path/to/foo.txt branch2:./relative/path/to/foo-another.txt

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

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