我看不到“提交更改”文件中的更改文件Android Studio中的屏幕 [英] I can't see changed files on "commit changes" screen in Android Studio

查看:82
本文介绍了我看不到“提交更改”文件中的更改文件Android Studio中的屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我转到 VCS>进行更改时,看到以下屏幕:

When I go to VCS>Commit changes, I see the following screen:

我可能误按了某个按钮或某些东西,从那时起我就无法提交整个项目,只有一个文件(.iml文件)。

为什么我看不到项目中的其他文件?。

I have probably pressed on some button or something by mistake, and since then I can't commit the whole project, just one file (the .iml file).
Why can't I see any other files that are in my project?.

推荐答案

首先要做的事情



正如您在前面的答案中提到的那样,您无法提交整个项目如你所说。您只能提交尚未记录的更改。

请记住,如果您看到提交更改屏幕中没有文件,则无需担心。您文件的更改是安全无害的,它们已由git记录下来,您不会丢失这些更改。

First Things First

As mentioned in the answer you’ve got before, you are not able to commit the whole project as you said. You are only able to commit changes that haven’t been recorded yet.
Bearing that in mind, if you see that there are no files in the "commit changes" screen there is no need to panic. The changes to your files are safe and sound, they have been recorded by git and you won’t lose those changes.

不过,不同意上一个答案。据我了解,您对项目进行的更改很少,但现在找不到它们。正如您在问题中所说的那样-您回想起偶然按下某些东西,现在文件已经从您可以提交的文件列表中消失了。

Nonetheless, disagree with the previous answer. From what I understood, you have made few changes to the project but now you can’t locate them. As you said in your question - you recall pressing on something by accident and now the files are "gone" from the list of files you are able to commit.

在这种情况下,让我们尝试共同找出那些更改可能在哪里。

有很多可能性:

In that case, let’s try to figure out together where those changes can be.
There are number of possibilities:


  1. 您可能选择了不将文件添加到git

  2. 您可能已添加文件以忽略列表

  3. 您可能已经隐藏了这些更改

  4. 您可能已经提交了更改,但尚未将其推送到远程存储库中

  1. Your might have selected not to add the file to git
  2. You might have added the files to ignore list
  3. You might have stashed those changes
  4. You might have committed the changes but haven't pushed them to your remote repository

首先,让我们介绍一下git记录更改的方式-

First, let’s cover the way git is recording changes -

Git正在跟踪您的文件,以查看文件是否有任何更改。如果是这样,git将注意到更改,您将能够提交更改。所有跟踪的文件均以未修改开头。然后,当您编辑它们时,它们被标记为已修改。

当您选择提交文件时,git会为它们准备提交,询问您要提交的文件,并将其标记出来

提交完成后,所有文件都恢复为未修改状态。

Git is tracking your files in order to see if there were any changes to the files. If so, git will notice the changes and you will be able to commit them. All tracked files start as "unmodified". Then, when you edit them they are marked as "modified".
When you chose to commit the files, git will prepare them for the commit, asking you which file you wish to commit and those will be marked as "staged".
After a commit is done, all the files are back to the "unmodified" status.

您可以阅读说明可以从 Git基础一书中获得更多信息:

You can read the explanation from the "Git Basics" book for further information:


请记住,工作目录中的每个文件都可以位于两个$ b $之一中b状态:已跟踪或未跟踪。跟踪的文件是最后快照
中的文件;它们可以不修改,修改或上演。未跟踪的
文件是其他所有内容–工作目录中
不在上一个快照中且不在暂存区中的任何文件。当您首次克隆
时,将跟踪所有文件,并且
不会被修改,因为Git只是签出了文件,而您没有编辑
的任何内容。

Remember that each file in your working directory can be in one of two states: tracked or untracked. Tracked files are files that were in the last snapshot; they can be unmodified, modified, or staged. Untracked files are everything else – any files in your working directory that were not in your last snapshot and are not in your staging area. When you first clone a repository, all of your files will be tracked and unmodified because Git just checked them out and you haven’t edited anything.

编辑文件时,Git认为它们已被修改,因为自从上次提交以来,您已经
进行了更改。暂存这些已修改的文件
,然后提交所有暂存的更改,然后重复该循环。

As you edit files, Git sees them as modified, because you’ve changed them since your last commit. You stage these modified files and then commit all your staged changes, and the cycle repeats.

根据规则,Android Studio将根据其在git中的状态标记目录中的文件。

By rule, Android Studio will mark the files in your directory according to their status in git.


  • 名称显示为蓝色时,表示文件已修改。

  • 当名称显示为绿色时,表示该文件是新文件,并且
    已添加到git跟踪的文件集中。

  • 名称显示为红色时,表示文件未跟踪。

  • 名称以白色/灰色显示时,表示文件未修改。

  • When the name appears in blue, that means the file is modified.
  • When the name appears in green, that means the file is a new one and was added to the set of files tracked by git.
  • When the name appears in red, that means the file is untracked.
  • When the name appears in white/gray, that means the file is unmodified.

如果您看到存储库中的某些文件名显示为红色,则可以:

右键单击=> git =>添加,它们就会被git跟踪,当您尝试提交时,您将能够看到它们。

If you see that some of the filenames in your repository appear in red, you can:
Right Click => Git => Add and they will be tracked by git and you will be able to see them when you are trying to commit.

Gitignore列表可让您指定要忽略的故意未跟踪的文件。

忽略列表基本上是一个文件包含您要git取消跟踪的工作目录中文件的位置。此列表将防止将未跟踪的文件添加到git跟踪的文件集中(请记住git将继续跟踪任何已被跟踪的文件)。

如果是这种情况,请添加gitignore列表中的文件将使其从您可以提交的文件列表中消失。

因此,要取回并再次提交,您需要将其从中删除。 gitignore列表。

为此,您需要在git命令行中键入 git add -A 命令。此命令将暂存目录中的所有文件(新的,已修改的,已删除的),这将解决您的问题。

此外,您还应该查看在Android Studio和Windows Server 2003上配置的已忽略文件列表

要访问忽略的文件列表,请转到 Project =>。设置=>版本控制=>忽略的文件(Windows和Linux)或 Android Studio菜单=>首选项=>版本控制=>忽略的文件(MacOS)。在其中,您可以将其从忽略的文件列表中删除。

Gitignore list will let you specify intentionally untracked files to ignore.
The ignore list is basically a file containing the locations of the files in your working directory that you would like git to untrack. This list will prevent untracked files from being added to the set of files tracked by git (bearing in mind that git will continue to track any files that are already being tracked).
If this is your case, adding a file to the gitignore list will make it "disappear" from the list of files you are able to commit.
So, in order to get it back and commit it again, you will need to remove it from the gitignore list.
In order to do that, you will need to type git add -A command into the git command line. This command will staged all files in your directory (new, modified, deleted) and it will solve your problem.
In addition, you should take a look at the Ignored Files list which is configured on Android Studio and make sure that files you are looking to commit aren’t there.
To access the Ignored Files list, go to Project => Settings => Version Control => Ignored Files (Windows and Linux) or Android Studio menu => Preferences => Version Control => Ignored Files (MacOS). In there, you will able to remove it from the "ignored files" list.

摘自《 Git基础知识》一书:

From the "Git Basics" book:


通常,当您在做零件时在您的项目中,事情处于
a混乱的状态,并且您想要切换分支以便在
上进行其他操作。问题是,您不想做一次
半完成的提交,只是想稍后再回到这一点。这个问题的
答案是git stash命令。

Often, when you’ve been working on part of your project, things are in a messy state and you want to switch branches for a bit to work on something else. The problem is, you don’t want to do a commit of half-done work just so you can get back to this point later. The answer to this issue is the git stash command.

隐藏将工作目录的脏状态(即
修改后的跟踪文件和分段更改)保存到
堆栈中您可以随时重新应用未完成的更改。

Stashing takes the dirty state of your working directory — that is, your modified tracked files and staged changes — and saves it on a stack of unfinished changes that you can reapply at any time.

您可能已保存了文件,但现在看来它们没有被修改,您无法提交它们。

为了取消存储它们(单击项目的主文件夹):

右键单击=> ; git =>存储库=> UnStash Changes…,然后从列表中选择最新的存储,然后单击 Apply Stash

如果您在列表中看不到任何内容,或者如果列表中没有包含您所做的最新更改,则情况并非如此。

You might have stashed your files, and now they appear to be unmodified and you aren’t able to commit them.
In order to un-stash them (clicking on the main folder of your project):
Right Click => Git => Repository => UnStash Changes… , then select the most recent stash from the list and click on "Apply Stash".
If you see nothing on the list, or if the list does not contain the latest changes you have made, then this is not your case.

最后一个可能的选择是,您已经提交了更改,但尚未将其推送到远程存储库中,因此您不必

如上所述,git commit命令将记录对文件的更改,但是这里最重要的是将其记录在本地存储库中.br

为了也更新远程存储库,您也需要使用git push命令来推动这些更改。

Android Studio提供了两项更改:提交更改,commit和推送更改。

您可能选择了提交更改,在这种情况下:

The last possible option is that you have already committed the changes but you haven’t pushed them to your remote repository so you don’t see them on the cloud/other computers.
As mentioned above, the git commit command will record changes to your file, but the most important thing in here is that is will be recorded on your local repository.
In order to update the remote repository as well you will need to push those changes too, using the git push command.
Android Studio offers two changes: commit changes and commit and push changes.
You might have chosen to commit the changes, and in that case:


  • 从本地存储库的角度来看:

    记录了更改,
    文件返回到未修改模式,您看不到它们
    不再显示在提交屏幕上,直到您将进行下一个
    更改为止。

  • 从远程存储库的角度来看:

    由于没有执行push命令,因此没有更新。

这里是

为了解决这个问题,您要做的就是通过以下方式将更改推送到远程存储库:

右键单击=> git =>存储库=>推送。这么简单。

In order to solve this, all you have to do is to push the changes to your remote repository by:
Right click => Git => Repository => Push. That simple.

以下是一些有用的链接:

Here are some helpful links:

  • Git Basics - Working with Remotes
  • Git Basics - Recording Changes to the Repository
  • Git Tools - Stashing and Cleaning

希望我的回答帮助您解决了问题:)

Hope my answer has helped you in solving your problem :)

这篇关于我看不到“提交更改”文件中的更改文件Android Studio中的屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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