如何区分本地未提交的更改和原点 [英] How to Diff between local uncommitted changes and origin

查看:114
本文介绍了如何区分本地未提交的更改和原点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我克隆了一个存储库并开始修改文件。我知道如果我有局部未提交的更改,我可以按如下方式进行差异化:code> git diff test.txt ,它会显示当前本地HEAD和修改之间的差异,文件中未提交的更改。如果我提交这些更改,我可以通过使用 git diff master master / master



来区别原始存储库在本地提交之前,是否有任何方法可以在服务器上使用原始存储库区分本地更改?我尝试了 git diff - 缓存的master origin / master 的各种排列,没有运气。

解决方案

鉴于远程仓库已通过 git fetch 进行了缓存,应该可以对这些提交进行比较。请尝试以下操作:

  $ git fetch origin 
$ git diff origin / master


Let's say I cloned a repository and started modifying files. I know that if I have local uncommitted changes, I can do a diff as follows git diff test.txt and it will show me the difference between the current local HEAD and the modified, uncommitted changes in the file. If I commit those changes I can diff it against the original repository by using git diff master origin/master

But is there any way of diff'ing the local changes with the original repository on the server before committing locally? I tried various permutations of git diff --cached master origin/master with no luck.

解决方案

Given that the remote repository has been cached via git fetch it should be possible to compare against these commits. Try the following:

$ git fetch origin
$ git diff origin/master

这篇关于如何区分本地未提交的更改和原点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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