You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android Studio类文件颜色编码:如何将红色类文件改为蓝色?

Fixing Red File to Blue in Android Studio (Git Tracking)

Hey there, let's break down what those colors mean first, then walk through how to get your red file to show up as blue:

What Do the Colors Represent?

  • Blue: Files tracked by Git that have no local changes (matches the version stored in your Git repository)
  • Red: Files that are untracked by Git—meaning Git hasn't been instructed to monitor changes to this file yet
  • Green: Files added to Git's staging area (via git add) but not yet committed to the repository

Step-by-Step to Turn Red File to Blue

Option 1: Using Android Studio's GUI

  1. Open the Git tool window at the bottom of Android Studio (or use the shortcut Alt+9)
  2. Locate your red file under the Unversioned Files section
  3. Right-click the file, then select Add to VCS (or hit Ctrl+Alt+A as a shortcut)
  4. The file will turn green next—open the Commit window (Ctrl+K), enter a clear commit message, and click Commit (or Commit and Push if you want to sync to a remote repo)
    Once committed, the file will switch to blue.

Option 2: Using the Terminal

  1. Open the Terminal tab at the bottom of Android Studio (it defaults to your project's root directory)
  2. Run this command to add the file to Git's staging area:
    git add your-file-name.java
    
    Replace your-file-name.java with the actual name of your red class file.
  3. Commit the file to your repository with a descriptive message:
    git commit -m "Add [Your Class Name] implementation"
    
    After committing, the file will display as blue in Android Studio.

Quick Note

Once the file is blue, it means Git is tracking it and your local version matches the one in the repo. It'll stay blue until you make edits to the file (then it'll shift to yellow/orange, depending on your IDE settings).

内容的提问来源于stack exchange,提问作者Francis Albert Calas

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:37:47