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
- Open the
Gittool window at the bottom of Android Studio (or use the shortcutAlt+9) - Locate your red file under the
Unversioned Filessection - Right-click the file, then select
Add to VCS(or hitCtrl+Alt+Aas a shortcut) - The file will turn green next—open the
Commitwindow (Ctrl+K), enter a clear commit message, and clickCommit(orCommit and Pushif you want to sync to a remote repo)
Once committed, the file will switch to blue.
Option 2: Using the Terminal
- Open the
Terminaltab at the bottom of Android Studio (it defaults to your project's root directory) - Run this command to add the file to Git's staging area:
Replacegit add your-file-name.javayour-file-name.javawith the actual name of your red class file. - Commit the file to your repository with a descriptive message:
After committing, the file will display as blue in Android Studio.git commit -m "Add [Your Class Name] implementation"
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
相关产品推荐
相关产品推荐

