Auto Push & Delete Branch Tool is a Python script that automates managing multiple Git repositories — perfect for large Android-based projects such as AOSP, or LineageOS that contain dozens or even hundreds of repositories.
- 🌐 Dual language support: English & Indonesian
- ⚡ Easy configuration via
.env - 🔗 Supports local → remote repo mapping (
local_folder:github_repo) - 🏗️ Automatically creates repositories on GitHub if missing
- 🧹 Filters large files (>100MB) using
git-filter-repo - 📦 Batch push for large repositories
- 🗑️ Delete branches across multiple repositories
- 🧾 Saves detailed logs to
push_log.txt
-
Install Python dependencies
pip install requests PyGithub
-
Ensure system tools are installed
gitwgetgit-filter-repo(auto-installed if missing)
Create a file named .env in the same folder as the script and add the following:
BASE_DIR=/home/ubuntu/orion
REPO_LIST_FILE=repos.txt
BRANCH=bka
GITHUB_USERNAME=Wrdn28
GITHUB_TOKEN=ghp_your_github_token_here
GITHUB_ORG=OrionOS-Project
LOG_FILE=push_log.txt
BATCH_SIZE=50000| Variable | Description |
|---|---|
| BASE_DIR | Root folder containing all local repositories |
| REPO_LIST_FILE | File containing the list of repositories |
| BRANCH | Branch name to push or delete |
| GITHUB_USERNAME | Your GitHub username |
| GITHUB_TOKEN | Your GitHub Personal Access Token |
| GITHUB_ORG | GitHub organization name (leave blank if personal) |
| LOG_FILE | Log file name |
| BATCH_SIZE | Number of commits per push batch |
The repos.txt file lists all repositories to be processed.
Each line represents a local folder, optionally mapped to a different GitHub repo name using :.
Example:
android:manifest
build_make:build
frameworks_base
Explanation:
android:manifest→ local folderandroid, GitHub repomanifestbuild_make:build→ local folderbuild_make, GitHub repobuildframeworks_base→ same name locally and remotely
Run the script with:
python3 auto_push.pyYou’ll be asked to choose:
Select language / Pilih bahasa:
1. English
2. Bahasa Indonesia
Select mode:
1. Auto Push
2. Delete Branch
This mode will:
- Filter large files (>100MB) — applies only to
frameworks_base - Create the target branch if it doesn’t exist
- Auto-commit local changes
- Create GitHub repos if missing
- Push using batch system
- Perform a final push for remaining commits
Example Output:
⚙️ Filtering files larger than 100MB...
✅ Repository frameworks_base fully pushed!
This mode will:
- Ask for the branch name to delete
- Remove that branch from all repos in
repos.txt
Example Output:
=== Deleting Branch: main ===
🔍 Processing repo: frameworks_base
✅ Branch 'main' deleted from frameworks_base.
⚠️ Branch 'main' not found in vendor_lineage. Skipped.
=== Branch Deletion Complete ===
- Ensure each folder in
BASE_DIRis a valid Git repository (.git/exists). - Missing folders will be skipped automatically.
- All logs are saved to
push_log.txt. - Only repositories listed in
repos.txtare affected.
Developed by Hirokixd (Wrdn28)
Free to use, modify, and redistribute — attribution required.