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

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

问题描述

我更熟悉在命令行(尤其是 MacOS)上使用 git.但是,我有时会尝试使用 Android Studio VCS提交",因为它有时使用起来会稍微快一些.我今天遇到的一个奇怪的问题是,Android 的 Studio git "commit" 没有看到我的 4 个修改过的文件,而在命令行中,git status 清楚地显示了 4 个修改过的文件.我看过这个

我检查过的其他一些东西:

  1. Android Studio 中的项目路径与命令行中的路径匹配.(所以我不是在看 git repo 的不同副本)
  2. 我的 .gitignore 不排除那 4 个修改过的文件.无论如何,即使是这样,它也应该对命令行 git 和 Android Studio git 都这样做,对吗?
  3. Android Studio 中的Git 可执行文件路径"设置是 /usr/bin/git,与我从命令行使用 which git 得到的相同.

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

ps.之前可能也遇到过这样的问题,就直接开始用命令行了.但这一次,我希望能学到一些关于 Android Studio git 集成的新东西:-).

解决方案

问题是我的 Android Studio 设置(MacOS 中的首选项->版本控制)中列出了两个 git 根.不知道那是怎么发生的.对于这个项目,我的 git repo root 有两个子文件夹,而 android 项目在这两个文件夹之一中.不知何故,Android Studio 已将带有 android 项目的子文件夹添加为另一个 git 根目录(请参阅带有 2 个 git 根目录的屏幕截图).或者它可能是想聪明一点,建议我将该子文件夹添加为 git root,然后我不小心点击了确定".

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

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

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

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.

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

Some other things I checked:

  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. 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 :-).

解决方案

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".

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

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

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天全站免登陆