From e0c45f018d3bfe326f7f4c7946a51eaba1313239 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 14 Apr 2026 15:46:44 +0000 Subject: [PATCH 1/7] Initial plan From aff847d0506f2e9dbbecf92bdbea9a67cc544ab7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 14 Apr 2026 15:48:12 +0000 Subject: [PATCH 2/7] docs: add Git Bash on Windows subsection to installing guide Agent-Logs-Url: https://github.com/wp-cli/handbook/sessions/dd455d4f-9431-4eb1-ba86-838e994cfe8f Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- guides/installing.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/guides/installing.md b/guides/installing.md index ad2d5771..6b596c85 100644 --- a/guides/installing.md +++ b/guides/installing.md @@ -272,6 +272,32 @@ Add `c:\wp-cli` to your path: You can now use WP-CLI from anywhere in Windows command line. +#### Using WP-CLI with Git Bash on Windows + +If you use [Git Bash](https://gitforwindows.org/) as your shell on Windows, the `wp.bat` wrapper will not work. Instead, create a file named `wp` (no extension) in `c:\wp-cli` with the following contents: + +``` +#!/usr/bin/env sh + +dir=$(d=${0%[/\\]*}; cd "$d"; pwd) + +# See if we are running in Cygwin by checking for cygpath program +if command -v 'cygpath' >/dev/null 2>&1; then + # Cygwin paths start with /cygdrive/ which will break windows PHP, + # so we need to translate the dir path to windows format. However + # we could be using cygwin PHP which does not require this, so we + # test if the path to PHP starts with /cygdrive/ rather than /usr/bin + if [[ $(which php) == /cygdrive/* ]]; then + dir=$(cygpath -m $dir); + fi +fi + +dir=$(echo $dir | sed 's/ /\ /g') +"${dir}/wp-cli.phar" "$@" +``` + +You can now use `wp` from Git Bash. + ### Installing via .deb package On Debian or Ubuntu, just download and open one of the .deb packages: From 163400b28d772fc8de22a00cde7a2a86fe3fbb6f Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 14 Apr 2026 21:05:34 +0200 Subject: [PATCH 3/7] Update guides/installing.md Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- guides/installing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/installing.md b/guides/installing.md index 6b596c85..7f59c8f7 100644 --- a/guides/installing.md +++ b/guides/installing.md @@ -277,7 +277,7 @@ You can now use WP-CLI from anywhere in Windows command line. If you use [Git Bash](https://gitforwindows.org/) as your shell on Windows, the `wp.bat` wrapper will not work. Instead, create a file named `wp` (no extension) in `c:\wp-cli` with the following contents: ``` -#!/usr/bin/env sh +#!/usr/bin/env bash dir=$(d=${0%[/\\]*}; cd "$d"; pwd) From 47f48ab091143eeb2430f36f3679839acc90757f Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 14 Apr 2026 21:05:52 +0200 Subject: [PATCH 4/7] Update guides/installing.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- guides/installing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/installing.md b/guides/installing.md index 7f59c8f7..203aae0f 100644 --- a/guides/installing.md +++ b/guides/installing.md @@ -288,7 +288,7 @@ if command -v 'cygpath' >/dev/null 2>&1; then # we could be using cygwin PHP which does not require this, so we # test if the path to PHP starts with /cygdrive/ rather than /usr/bin if [[ $(which php) == /cygdrive/* ]]; then - dir=$(cygpath -m $dir); + dir=$(cygpath -m "$dir") fi fi From 15cc7e92b9c73357d8511af3efbc243264fe8f5c Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 14 Apr 2026 21:06:48 +0200 Subject: [PATCH 5/7] Update guides/installing.md Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- guides/installing.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/guides/installing.md b/guides/installing.md index 203aae0f..4df004d8 100644 --- a/guides/installing.md +++ b/guides/installing.md @@ -292,8 +292,7 @@ if command -v 'cygpath' >/dev/null 2>&1; then fi fi -dir=$(echo $dir | sed 's/ /\ /g') -"${dir}/wp-cli.phar" "$@" +php "${dir}/wp-cli.phar" "$@" ``` You can now use `wp` from Git Bash. From 605cb19c926bccf9780ddcfb10f9e06fcc25a54b Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 14 Apr 2026 21:07:15 +0200 Subject: [PATCH 6/7] Update guides/installing.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- guides/installing.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/guides/installing.md b/guides/installing.md index 4df004d8..a0a7e93d 100644 --- a/guides/installing.md +++ b/guides/installing.md @@ -279,7 +279,10 @@ If you use [Git Bash](https://gitforwindows.org/) as your shell on Windows, the ``` #!/usr/bin/env bash -dir=$(d=${0%[/\\]*}; cd "$d"; pwd) +script_path=$(command -v "$0" 2>/dev/null || printf '%s\n' "$0") +d=${script_path%[/\\]*} +[ "$d" = "$script_path" ] && d=. +dir=$(cd "$d" && pwd) # See if we are running in Cygwin by checking for cygpath program if command -v 'cygpath' >/dev/null 2>&1; then From d0fd73e27ec1e4231951718ceeb3ac643685edb5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 14 Apr 2026 19:08:57 +0000 Subject: [PATCH 7/7] docs: add chmod +x step for Git Bash wp wrapper Agent-Logs-Url: https://github.com/wp-cli/handbook/sessions/95978eb1-7a0d-4e19-8163-cddb00121451 Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- guides/installing.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/guides/installing.md b/guides/installing.md index a0a7e93d..5b11c481 100644 --- a/guides/installing.md +++ b/guides/installing.md @@ -298,6 +298,12 @@ fi php "${dir}/wp-cli.phar" "$@" ``` +Then make the file executable: + +``` +chmod +x /c/wp-cli/wp +``` + You can now use `wp` from Git Bash. ### Installing via .deb package