Skip to content

Latest commit

Β 

History

History
158 lines (117 loc) Β· 3.68 KB

File metadata and controls

158 lines (117 loc) Β· 3.68 KB

πŸš€ Auto Push & Delete Branch Tool

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.


βš™οΈ Key Features

  • 🌐 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

🧰 Requirements

  1. Install Python dependencies

    pip install requests PyGithub
  2. Ensure system tools are installed

    • git
    • wget
    • git-filter-repo (auto-installed if missing)

βš™οΈ .env Configuration

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

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

πŸ“„ repos.txt Format

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 folder android, GitHub repo manifest
  • build_make:build β†’ local folder build_make, GitHub repo build
  • frameworks_base β†’ same name locally and remotely

πŸš€ How to Run

Run the script with:

python3 auto_push.py

You’ll be asked to choose:

1️⃣ Language

Select language / Pilih bahasa:
1. English
2. Bahasa Indonesia

2️⃣ Mode

Select mode:
1. Auto Push
2. Delete Branch

πŸ”Ή Auto Push Mode

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!

πŸ”Ή Delete Branch Mode

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 ===

🧠 Notes

  • Ensure each folder in BASE_DIR is 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.txt are affected.

🧾 License

Developed by Hirokixd (Wrdn28)
Free to use, modify, and redistribute β€” attribution required.