repo status

The repo status command in the Repo tool is used to display the status of all the repositories in a project. It provides information about the current branch, the tracking branch, and any changes that have been made but not yet committed. This command is crucial for tracking the state of your project repositories and understanding any uncommitted or untracked changes.

Purpose of repo status:

The primary purpose of repo status is to give an overview of the state of each repository managed by Repo. This includes:

  • Showing the currently checked-out branch.

  • Displaying the upstream branch being tracked (if any).

  • Listing any modified, staged, or untracked files in each repository.

  • Helping users review changes before committing or syncing.

What Happens When You Run repo status?

When you run the repo status command, Repo checks each repository defined in the manifest and gathers information about:

  • The current branch that is checked out in each repository.

  • The upstream branch (if applicable) that the current branch is tracking.

  • Any changes that have been made to tracked or untracked files.

  • Staged changes that are ready to be committed.

It essentially runs a combination of git status and branch-tracking information for each repository, presenting a consolidated report.

Example Command:

repo status

Example Output and Explanation:

Let’s consider the output of repo status and break it down:

Output Explanation:

  1. Project Path and Branch Information:

    • project_path_1: This is the relative path to the repository from the root of your project.

    • branch_name: The currently checked-out branch in this repository.

    • (tracking branch origin/branch_name): This indicates that the current branch is tracking an upstream branch named origin/branch_name. This means that changes will be pushed to or pulled from this remote branch.

  2. File Status:

    • file_1.txt: modified: This indicates that file_1.txt has been modified locally but has not yet been staged or committed.

    • file_2.cpp: untracked: This indicates that file_2.cpp is a new file in the working directory that is not being tracked by Git yet.

  3. Additional Projects:

    This shows similar information for another project (project_path_2), with file_3.py being modified locally.

Use Cases for repo status:

  1. Reviewing Local Changes: Before committing or syncing, running repo status allows you to review any local changes that have been made. You can identify modified files, untracked files, and see which branch you are on.

  2. Checking Branch Consistency: If you are working on multiple repositories, repo status provides an easy way to check which branch you are currently working on in each repository and whether those branches are tracking upstream branches.

  3. Identifying Untracked Files: The command helps in identifying any files that are not yet being tracked by Git, allowing you to decide whether to add them to the repository or ignore them.

  4. Before Running repo sync: It is a good practice to run repo status before running repo sync to ensure there are no uncommitted changes that might get lost during the sync process.

Example Workflow:

Let’s assume you are working on an AOSP-based project. Here’s a typical workflow:

  1. Run repo status to Check the Project State:

  2. Review the Output: You see the following output:

    From this output, you can tell that:

    • In the system/core repository, you are on the feature_branch branch, and there are uncommitted changes to Android.mk. There is also an untracked file, README.md.

    • In the build/soong repository, you are on the master branch, and there are uncommitted changes to soong.config.

  3. Decide on Actions: Based on this output, you might decide to:

    • Stage and commit the changes to Android.mk and soong.config.

    • Decide whether to add README.md or ignore it.

    • Push changes to the upstream branches or pull any additional changes from the remote.

Summary of repo status:

  • Purpose: To give an overview of the state of each repository managed by Repo.

  • Usage: Run repo status to see the current branch, tracking branch, and the status of modified or untracked files in each repository.

  • Example Output: Displays each repository with its checked-out branch, tracking branch, and lists modified or untracked files.

  • When to Use: Use repo status before committing, syncing, or making branch changes to verify the project’s state.

If you need more specific examples or explanations of each type of file status shown in repo status, let me know!

Last updated