有没有一种快速的方法来“git diff”从点或分支的起源? [英] Is there a quick way to "git diff" from the point or branch origin?

查看:86
本文介绍了有没有一种快速的方法来“git diff”从点或分支的起源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看过使用 git diff 和git修订版(HEAD,ORIG_HEAD,FETCH_HEAD等)的各种SO答案,但我仍然没有找到简单的方法列出自从本地分支开始以来或自上次发生变更以来所做的更改。



通过 easy 我的意思是不必看并且粘贴提交SHA或必须计算我想回顾的提交数量。

git diff origin / master 很接近,但它指的是远程,因为我从它检出了新的分支,可能已经发生分歧。



我希望可以使用 git diff BASE_HEAD



...除非已经有办法做到这一点。有没有人有答案?

解决方案

使用 git diff @ {u} ... HEAD <

有两个点,或者 HEAD 省略,它会显示

有三个点,它只会显示你身边变化的差异。



<编辑:对于需求略有不同的用户,你可能会对 git merge-base 感兴趣(注意它有比其他答案用途更多的选项)。 p>

I have looked at various SO answers on using git diff and git revisions (HEAD, ORIG_HEAD, FETCH_HEAD, etc.) and I still haven't found an easy way to list the changes have been made since the beginning of the local branch, or since last rebase.

By easy I mean without having to look up and paste commit SHA or having to count how many commits I want to look back.

git diff origin/master is close, but it refers to remote which may have diverged since I checked out new branch from it.

I would expect something like git diff BASE_HEAD to be available.

...unless there's already a way to do that. Does anyone have the answer?

解决方案

Use git diff @{u}...HEAD, with three dots.

With two dots, or with HEAD omitted, it will show diffs from changes on both sides.

With three dots, it will only show diffs from changes on your side.

Edit: for people with slightly different needs, you might be interested in git merge-base (note that it has plenty more options than the other answer uses).

这篇关于有没有一种快速的方法来“git diff”从点或分支的起源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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