Skip to content

dameng324/install-pacman-on-git-bash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

install-pacman-on-git-bash

Install pacman on Windows Git Bash

Overview

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.


Features

  • Downloads pacman, pacman-mirrors, and msys2-keyring packages.
  • Supports choosing between:
    • Official MSYS2 mirror (https://mirror.msys2.org)
    • Tsinghua University mirror (recommended for users in mainland China)
  • Automatically extracts .pkg.tar.zst files 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 -Syu inside Git Bash.
  • Optional cleanup of temporary download and extraction directories.
  • Fully colored output for better visibility.
  • Supports non-interactive automation for CI or scripting.

Requirements

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

Usage

Interactive Mode (default)

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)

Non-Interactive Mode

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

Available Flags

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.

Notes

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

License

This script is provided as-is under the MIT License. Use at your own risk.

About

Install pacman on Windows Git Bash

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages