Android Studio的git commit看不到我修改过的文件 [英] Android Studio's git commit not seeing my modified files

查看:659
本文介绍了Android Studio的git commit看不到我修改过的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我更熟悉在命令行上使用git(尤其是MacOS).但是,我有时会尝试使用Android Studio VCS提交",因为有时使用起来会稍快一些.我今天遇到的怪异问题是Android Studio git"commit"看不到我的4个修改文件,而在命令行中,git status清楚地显示了4个修改文件.我已经看过 Stack Overflow帖子,并且我已经检查了它不是由于以下任何原因(例如,未将文件添加到git存储库中,或者已被隐藏等).此外,由于git status显示了文件,因此它们清楚地位于存储库中,没有被隐藏,并且对其进行了 修改.

I am more familiar with using git on the command line (MacOS, especially). However, I sometimes try to use the Android Studio VCS "commit", as it is sometimes slightly faster to use. The weird problem that I came across today is that Android's Studio git "commit" does not see my 4 modified files, whereas from the command line, git status shows clearly the 4 modified files. I have seen this Stack Overflow post and I have checked it is not for any of these reasons (like, not adding the file to the git repository, or it is stashed, etc,). Besides, since git status shows the files, they are clearly in the repo, they are not stashed, and they are modified.

这是来自Android Studio和命令行的屏幕截图,显示了差异.

Here are the screenshots from Android Studio and from the command line showing the discrepancy.

我检查了一些其他内容:

Some other things I checked:

  1. Android Studio中的项目路径与命令行上的路径匹配. (因此,我不会查看git repo的其他副本)
  2. 我的.gitignore不排除这4个修改后的文件.无论如何,即使是这样,对于命令行git和Android Studio git都应该这样做,对吗?
  3. Android Studio中的"Git可执行文件的路径"设置为/usr/bin/git,与我在命令行中通过which git获得的内容相同.
  1. The project path in Android Studio matches with the path on the command line. (so I'm not looking at a different copy of the git repo)
  2. My .gitignore is not excluding those 4 modified files. In any case, even if it is, it should be doing that for both the command line git and the Android Studio git, right?
  3. The "path to Git executable" setting in Android Studio is /usr/bin/git, same as what I get with which git from the command line.

任何想法可能是什么问题?

Any ideas what may be the problem?

ps.我以前可能遇到过这样的问题,只是继续使用命令行.但是这次,我希望学习有关Android Studio git集成的新知识:-).

ps. I may have encountered such a problem before, and just proceeded to use the command line. But this time, I hope to learn something new about the Android Studio git integration :-).

推荐答案

问题原来是我在Android Studio设置(MacOS中的首选项"->版本控制")中列出了两个git根目录.不知道怎么回事.对于此项目,我的git repo根目录具有两个子文件夹,而android项目位于这两个文件夹之一中.不知何故,Android Studio已将带有android项目的子文件夹添加为另一个git根目录(请参见具有2个git根目录的屏幕截图).也许是它试图变得聪明,建议我将子文件夹添加为git根,然后我不小心单击了确定".

The problem turned out to be that I had two git roots listed in my Android Studio settings (Preferences->Version Control in MacOS). Not sure how that happened. For this project, my git repo root has two subfolders, and the android project is in one of those two folders. Somehow, Android Studio had added the subfolder with the android project as another git root (see the screenshot with the 2 git roots). Or maybe it was trying to be clever and suggested that I add that subfolder as a git root, and I carelessly clicked "ok".

因此,我删除了指向我的android项目的git根目录.然后看起来像这样,

So, I removed the git root that pointed to my android project. Then it looks like this,

现在,Android Studio中的git集成再次正常工作.

And now, git integration in Android Studio is working properly again.

以防万一将来这种情况发生,请检查您的Android Studio git根目录(以及Git可执行文件的路径,位于Preferences-> Version Control-> Git).

Just in case this happens to anyone else in the future, check your Android Studio git roots (and path to Git executable too, at Preferences->Version Control->Git).

这篇关于Android Studio的git commit看不到我修改过的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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