Install pacman on Windows Git Bash
This script bootstraps an MSYS2-like environment inside Windows Git Bash.
It downloads essential MSYS2 packages, extracts them, copies them to a Git Bash root directory structure, initializes the pacman keyring, and performs a full system upgrade inside this environment.
It is intended for Git Bash users on Windows who want to use pacman and related tools without installing a full MSYS2 distribution.
- Downloads
pacman,pacman-mirrors, andmsys2-keyringpackages. - Supports choosing between:
- Official MSYS2 mirror (
https://mirror.msys2.org) - Tsinghua University mirror (recommended for users in mainland China)
- Official MSYS2 mirror (
- Automatically extracts
.pkg.tar.zstfiles using 7-Zip 24.01+. - Copies files to a Git Bash root directory, overwriting if necessary.
- Initializes and populates the pacman keyring in Git Bash.
- Performs a system upgrade with
pacman -Syuinside Git Bash. - Optional cleanup of temporary download and extraction directories.
- Fully colored output for better visibility.
- Supports non-interactive automation for CI or scripting.
- Windows OS (script must run in Git Bash).
The script will fail if run on Linux, macOS, or WSL. - Git Bash installed and run as Administrator.
- 7-Zip version 24.01 or newer installed and accessible in PATH or at:
C:\Program Files\7-Zip\7z.exe - Internet access to download MSYS2 packages from your chosen mirror.
Run the script normally to select mirror and cleanup options interactively:
bash <(curl -fsSL https://raw.githubusercontent.com/dameng324/install-pacman-on-git-bash/main/install.sh)For automation (CI/CD or unattended setups), use the following options:
bash <(curl -fsSL https://raw.githubusercontent.com/dameng324/install-pacman-on-git-bash/main/install.sh) --non-interactive --mirror tsinghua --cleanup| Flag | Description |
|---|---|
--non-interactive | Skip all prompts, use defaults. |
--mirror official | Use the official MSYS2 mirror (mirror.msys2.org). |
--mirror tsinghua | Use the Tsinghua University mirror (recommended for China). |
--cleanup | Automatically delete temporary download and extraction directories. |
--no-cleanup | Keep temporary files after completion. |
- Administrator privileges are required because files are copied to the Git Bash root directory structure.
- The script outputs clear, colored steps and warnings for easy monitoring.
- If you experience download failures, verify your internet connection and mirror accessibility.
- Temporary directories (downloads and extraction) are kept by default unless cleanup is chosen.
- This script is not intended for full MSYS2 users; if you already have MSYS2, pacman is already included.
This script is provided as-is under the MIT License. Use at your own risk.