简体   繁体   English

Git在跟踪文件中找不到更改

[英]Git not finding changes in tracked files

I have a very odd problem: git has suddenly stopped being able to detect that I've modified files. 我有一个非常奇怪的问题:git突然停止能够检测到我已修改文件。 I can go into a repository's folder, change a tracked file, and git status will say: 我可以进入存储库的文件夹,更改跟踪文件,并且git status会显示:

# On branch master
nothing to commit (working directory clean)

This is especially strange because it took effect gradually. 这尤其奇怪,因为它逐渐生效。 First git-gui stopped being able to notice file changes, but the command line continued to work. 首先git-gui停止能够注意到文件更改,但是命令行继续起​​作用。 Then I restarted the machine and now neither the gui nor the command line can spot changed files. 然后,我重新启动了计算机,现在gui和命令行都无法发现更改的文件。

My best guess is that something is wrong with my PATH. 我最好的猜测是我的PATH出了点问题。 That would explain restarting the machine making it worse, and how the command line could have continued functioning for longer (it was started when the PATH was correct). 这将说明重新启动计算机会使情况变得更糟,以及如何使命令行继续运行更长的时间(在PATH正确时启动)。 Coworkers sometimes use my machine, so they may have installed something that modified the path. 同事有时会使用我的机器,因此他们可能安装了一些修改路径的东西。

In case it's relevant, here's my PATH: 如果相关,这是我的PATH:

echo $PATH
/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin
:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin
:/usr/local/git/bin

The machine in question is a mac mini. 有问题的机器是Mac mini。 Note that xcode can still detect the changes, and perform commits. 请注意,xcode仍然可以检测到更改并执行提交。 But that will only get me so far, until I need some command line specific feature. 但这只会使我到目前为止,直到我需要一些命令行特定的功能为止。

I'm unsure how to proceed. 我不确定如何进行。 How do I diagnose what's wrong? 如何诊断出什么问题? If the problem is PATH, then what do I reorder/remove/add? 如果问题是路径,那么我该如何重新排序/删除/添加? Secondarily, how do I figure out what broke things in the first place? 其次,我如何弄清楚什么是最坏的事情?

Turns out my coworker made another clone of the repository. 原来我的同事做了另一个仓库的克隆。 I thought I was modifying files in the original repo, when I modified them in xcode, but actually I was modifying them in the cloned repo. 当我在xcode中修改文件时,我以为是在原始存储库中修改文件,但实际上我是在克隆的存储库中对其进行修改的。

git status worked in the command line, temporarily, because that command line instance was left by my coworker and pointed to the correct directory. git status暂时在命令行中起作用,因为该命令行实例是我的同事留下的,并指向正确的目录。 Terminal only shows the name of the current directory, and I had no idea it was nested within the wrong directory. 终端仅显示当前目录的名称,我不知道它嵌套在错误的目录中。 git-gui 'broke first' because my co-worker didn't use git-gui, and so didn't point it at the clone. git-gui“先中断”是因为我的同事没有使用git-gui,因此也没有将其指向克隆。

So, just a dumb mistake on our part. 因此,我们这只是一个愚蠢的错误。 git was working properly. git工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM