git status显示修改过的文件,但是git diff什么都不显示 [英] git status shows modified files, but git diff shows nothing

查看:476
本文介绍了git status显示修改过的文件,但是git diff什么都不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经完成了"git reset --soft HEAD ^" 来删除提交中的某些文件,但是我遇到了一些问题.

I have done "git reset --soft HEAD^" to get rid of some files from commit, but I have some problems.

命令"git status" 显示文件列表(已修改-绿色).但是,如果我想显示使用命令"git diff" 进行的更改,git不会显示任何内容.另外,当我尝试通过"git checkout< FILE>" 还原更改时,没有任何结果.

Command "git status" shows list of files (modified -- green). But if I want to shows changes with command "git diff" git shows nothing. Also when I trying revert changes by "git checkout <FILE>" it gives no result.

如果我打开这些文件中的任何一个,我都会看到我的更改.

If I open any of these files I see my changes.

推荐答案

我已经完成了"git reset --soft HEAD ^"以摆脱提交中的某些文件,但是我有一些问题.命令"git status"显示文件列表(已修改-绿色).

I have done "git reset --soft HEAD^" to get rid of some files from commit, but I have some problems. Command "git status" shows list of files (modified -- green).

根据文档,此预期行为:

This expected behavior according to documentation:

-soft

完全不触摸索引文件或工作树(但将头重置为,就像所有模式一样).这留下了所有您更改过的文件要提交的更改",就像git status一样它.

Does not touch the index file or the working tree at all (but resets the head to , just like all modes do). This leaves all your changed files "Changes to be committed", as git status would put it.

将来使用-mixed 标志将文件移动到未暂存的区域

In future use --mixed flag to move files to not-staged area

git reset --mixed HEAD^

或者只是:

git reset HEAD^

因为默认使用-mixed

当前情况可以通过以下方式解决:

The current situation may be fixed by:

git reset HEAD -- <file>

这将使文件暂存.或者没有-< file 应用于所有文件.

This will make a file unstaged. Or without -- <file to apply to all files.

或使用 git diff --cached 显示暂存文件的差异.

Or use git diff --cached to show diff of staged files.

此外,当我尝试通过"git checkout"还原更改时,它没有任何结果.

Also when I trying revert changes by "git checkout " it gives no result.

如果文件未登台,则

git checkout< FILE> 起作用.

git checkout <FILE> works if file is unstaged.

这篇关于git status显示修改过的文件,但是git diff什么都不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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