How to Use repo forall to Get Git Diff Between Two Tags in AOSP

If you’re working with the Android Open Source Project (AOSP), managing a vast number of Git repositories can be overwhelming—especially when you want to check what has changed between two specific tags across the entire source tree. Fortunately, the repo forall command simplifies this task by allowing you to run Git commands across all projects at once.

In this guide, we’ll show you how to use repo forall to identify all changes between two Git tags (004.009 and 004.010) in your Android repo environment, including summaries, full diffs, and filtered outputs.


🛠 Command to Get File Change Summary Across All Projects

To see which files have changed between two tags in all AOSP repositories:

repo forall -c 'echo "$REPO_PATH"; git diff --stat TAG_V1 TAG_V2'

This command outputs:

  • The name of each repository ($REPO_PATH)
  • A summary of file changes (number of lines added/removed)

📄 Command to Get Full Diffs Across All Git Repositories

If you need the full diff instead of just a summary:

repo forall -c 'echo "$REPO_PATH"; git diff TAG_V1 TAG_V2'

This prints the entire line-by-line differences in every Git repository under your repo-managed Android source tree.


🧵 Generate a Unified Patch File for All Changes

Want to save all diffs into a single patch file for review or code sharing?

repo forall -c 'git diff TAG_V1 TAG_V2' > combined_diff.patch

This creates a combined_diff.patch file containing the full diff from all projects.


🕵️ Only Show Repositories That Have Changes

If you’re only interested in which projects actually have any difference between the two tags:

repo forall -c '[ "$(git diff TAG_V1 TAG_V2)" ] && echo "$REPO_PATH has changes"'

This skips repositories without any changes and lists only the modified ones.

The repo forall tool is an essential utility when working with Android’s multi-repo structure. Whether you’re preparing release notes, debugging, or conducting code reviews, these commands help you quickly identify and analyze code changes between any two Git tags across the entire AOSP project.

Stay organized, save time, and manage large codebases more efficiently with these simple but powerful tricks.

Leave a Comment