devguide icon indicating copy to clipboard operation
devguide copied to clipboard

Bug: Checking out others pull request (via git alias) in git bootcamp is resulting in an error

Open XChaitanyaX opened this issue 4 months ago • 8 comments

Describe the bug

tested OS-Windows

Screenshots

Image

Additional context

No response

XChaitanyaX avatar Aug 28 '25 10:08 XChaitanyaX

The relevant section for reference: https://devguide.python.org/getting-started/git-boot-camp/#checking-out-others-pull-requests.

Note that the git config command in the screenshot isn't quite the same as the one in the devguide. The devguide command uses single quotes (') around the alias string while the command in the screenshot uses double quotes ("). That distinction is important, since using single vs double quotes changes how variable expansions like ${1} work. See for example https://stackoverflow.com/questions/6697753/difference-between-single-and-double-quotes-in-bash for more details. The command should work if you copy-paste the git config command from the devguide exactly as written.

brianschubert avatar Aug 28 '25 11:08 brianschubert

@brianschubert Thank you for looking into this :) I actually did copy paste it. I don't see the difference b/w the screenshot above and this (image directly from the dev guide):

Image

and here is the copied text: git config --global alias.pr "!sh -c 'git fetch upstream pull/${1}/head:pr_${1} && git checkout pr_${1}' -"

I did verify it again by copy-pasting the command still the same as the initial screenshot

seems like you are looking at Unix/MacOS command which is exactly as described by you: git config --global alias.pr '!sh -c "git fetch upstream pull/${1}/head:pr_${1} && git checkout pr_${1}" -'

XChaitanyaX avatar Aug 28 '25 12:08 XChaitanyaX

Ah, I see. Thanks for clarifying. What shell are you using? From the screenshot, it looks like you're using git bash or another Unix-like environment, in which case you'd need to use the Unix command.

brianschubert avatar Aug 28 '25 12:08 brianschubert

Using PowerShell in windows

XChaitanyaX avatar Aug 28 '25 12:08 XChaitanyaX

Maybe I need to stop decorating the terminal (it definitely looks like Unix/bash) 😅

XChaitanyaX avatar Aug 28 '25 12:08 XChaitanyaX

Interesting! I don't have experience with PowerShell, so I have no idea what the expected quoting behavior is. It's possible that the Windows command in the devguide was written with cmd.exe in mind, not PowerShell. Does reversing the quotes like in the Unix command work on PowerShell?

brianschubert avatar Aug 28 '25 12:08 brianschubert

I did use the Unix/MacOS command in the terminal and here is the screenshot (not working)

Image

XChaitanyaX avatar Aug 28 '25 12:08 XChaitanyaX

and the command correctly works in the Command Prompt (cmd.exe in windows)

Image

XChaitanyaX avatar Aug 28 '25 12:08 XChaitanyaX