“git diff”什么也没做 [英] "git diff" does nothing

查看:104
本文介绍了“git diff”什么也没做的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为这是一个配置错误,但我无法弄清楚在哪里。常规的git命令似乎工作正常,但git diff什么都不做。为了安全起见,我从.gitconfig文件中删除了外部差异工具。这是通过MacPorts安装的,并且是lates版本(1.7.2.2)。

I presume this is a configuration error somewhere, but I can't figure out where. Regular git commands appear to work fine, but "git diff" does nothing. To be safe, I removed external diff tools from my .gitconfig file. This was installed via MacPorts and is the lates version (1.7.2.2).

我看到的是当我从工作区运行git diff时,它只是退出,无所作为。

What I see is that when I run "git diff" from my workspace, it simply exits, doing nothing.

$ git --version
git version 1.7.2.2
$ git diff
$ 

如果我备份了一个目录,在我的根目录工作空间外键入git diff 给我这个:

If I back up one directory, out of my root workspace, typing "git diff" gives me this:

$ git diff
usage: git diff [--no-index] <path> <path>

这可能是预期的行为,因为我不在git仓库中。

This may be expected behavior since I'm not under a git repository.

有什么想法可以解决这个问题?

Any ideas on what I can do to troubleshoot this?

推荐答案

code> git diff 是没有被提交/添加到索引的更改列表。如果没有变化,那么就没有输出。

The default output for git diff is the list of changes which have not been committed / added to the index. If there are no changes, then there is no output.


git diff [--options] [ - ] [... ]

这种形式是查看你相对于索引所做的修改(下一次提交的暂存区域)。换句话说,不同之处在于你可以告诉git进一步添加到索引中,但你仍然没有。

This form is to view the changes you made relative to the index (staging area for the next commit). In other words, the differences are what you could tell git to further add to the index but you still haven't.

有关更多详细信息,请参阅文档。特别是,向下滚动到示例,并阅读本节:

See the documentation for more details. In particular, scroll down to the examples, and read this section:

$ git diff            # (1)
$ git diff --cached   # (2)
$ git diff HEAD       # (3)




  1. 使用索引对工作副本进行分析

  2. 使用HEAD对索引进行区分

  3. 使用HEAD来区分工作副本

在你的工作空间之外,正如你猜测的那样,git不知道要分辨什么,所以你必须明确指定两条路径进行比较,使用信息。

Outside your workspace, as you guessed, git won't know what to diff, so you have to explicitly specify two paths to compare, hence the usage message.

这篇关于“git diff”什么也没做的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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