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.