如何在Git中显示本地文件和远程文件之间的差异? [英] How do I show differences between local and remote files in Git?
问题描述
由于我是Git的新手,因此上手时会遇到一些麻烦(Git版本2.12.3).
Since I am new to Git, I have some trouble getting started (Git version 2.12.3).
我在服务器上创建了一个文件(在GitLab中),可以将其克隆到本地目录中.
I created on a server a file (in GitLab) which I can clone to a local directory.
git clone git@gitlab.server.com:/joe/myproject.git
很好,我有文件的本地副本.但是,当我将远程内容更改为文件(从其他人或服务器上)时,即使在主客户端上可以清楚看到,也无法跟踪或看到本地客户端上的更改.不能
All fine, and I have a local copy of the file. But when I change remote something to the file (from someone else or on the server), then I am not able to track or to see the changes on the local client, even if they are clearly visible on the master. Not with
git diff file1
或
git diff origin/master
或其他内容.
我必须获取文件,将其合并,然后才能看到新编辑的内容. 在获取新文件之前是否可以观察并检测到新变化?
I have to fetch the file, merge it, and then I am able to see the newly edited content. Is it possible to observe and detect the new changes before fetching the new file?
推荐答案
为了满足您的需求,您至少需要从远程存储库中fetch
.只有这样-在merge
之前,您可以diff
在branch
和origin/branch
之间.
In order to accomplish your needs, you need at least to fetch
from your remote repository. And only then -and before you merge
- you can diff
between your branch
and your origin/branch
.
这篇关于如何在Git中显示本地文件和远程文件之间的差异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!