且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么会git日志/状态返回没有输出?

更新时间:2023-02-20 09:07:56

这个症状有两个可能的诊断:

A不区分大小写强制重命名回历史记录



诊断:



  git ls-files 

搜索大小写不同的路径:

  some / path / foo 
Some / path / bar



解决方案



  git mv -f Some / path / * some / path / 

将所有文件( / * )移动到重命名的路径。现在他们都会有一条路径。



可能的原因



some / path 有几个文件,用路径中的不同字母大小写进行跟踪。对于提供到 git log git status 的错误路径的文件,会导致日志中的某些提交异常输出。



这个bug可以用 git mv -f< path / file>

  $ c> git log某些/ path / foo 

日志不会 包含一些在 git mv -f some / path / bar前执行的一些提交。



标有 skip-worktree 的文件假定 - 不变的位



感谢@Zeeker的这个假设。

诊断:



  git ls-files -v | grep -E'^(S | [az])'

有关更多信息,请参阅 git ls-files 文档


I have a very old git repository (about six years old) and noticed that I wasn't seeing changes I'd made to a file in my git status output.

I ran the command on the specific file in question:

$ git status Data/schema.sql
$

and got no output! This file has been in the repo since the beginning. Additionally, if I checkout the repo to another directory, the file (strangely enough) appears there.

I saw the same with git diff Data/schema.sql and git log Data/schema.sql.

Normally, when something like this happens, it's a gitignore problem. But even removing my .gitignore file caused no change in this behavior.

What could cause this behavior?

This "symptom" has two possible "diagnoses":

A case-insensitive forced rename back in history

Diagnostics:

git ls-files

Search for paths with different capitalizations:

some/path/foo
Some/path/bar

Solution

git mv -f Some/path/* some/path/

It's important to move all files (/*) to the renamed path. Now they will all have a single path.

Possible cause

There may be a situation when some/path has several files with it, tracked with different letter cases in the path. For such files providing an "incorrect" path to git log or git status results in abscense of some commits in the log output.

This bug is reproduceable with git mv -f <path/file> <PATH/file> on Git 1.9.5 and maybe on newer versions (will check later).

git log Some/path/foo

The log will not contain some commits made before the git mv -f some/path/bar Some/path/bar was executed.

Files marked with a skip-worktree or assume-unchanged bit

Thanks to @Zeeker for this assumption.

Diagnostics:

git ls-files -v | grep -E '^(S|[a-z])'

For additional information take a look at the git ls-files documentation.