Skip to content

fix: use quiet checkout to avoid exception on git checkout#1792

Merged
mnriem merged 1 commit intogithub:mainfrom
B-SRIKRISHNAN:fix-git-checkout-exception
Mar 10, 2026
Merged

fix: use quiet checkout to avoid exception on git checkout#1792
mnriem merged 1 commit intogithub:mainfrom
B-SRIKRISHNAN:fix-git-checkout-exception

Conversation

@B-SRIKRISHNAN
Copy link
Contributor

Description

Fix Git checkout inside try catch raising exception causing failure of create_new_feature.ps1 script

Testing

Replicate the issue in a standalone script.

Test the script itself in a sample project by running it after making changes.

The issue was caused by a combination of git checkout writing output to error stream and $ErrorActionPreference set to stop, leading to powershell raising Exception on outputs to error steam (invoking 2> $null)

The fix is adding a quiet parameter ensuring no output is sent by git on successful checkout.

AI Disclosure

  • I did not use AI assistance for this contribution
  • I did use AI assistance (describe below)

Consulted GPT on what causes the issue, to understand the underlying cause, test it in a standalone script, replicating it

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes create-new-feature.ps1 failing during branch creation when git checkout emits output to the error stream under $ErrorActionPreference = 'Stop', by making the checkout operation quiet.

Changes:

  • Add Git’s quiet flag to git checkout -b to prevent stderr output on successful checkout.
  • Preserve existing flow: try/catch around checkout + $LASTEXITCODE check + fallback branch-exists detection.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mnriem mnriem merged commit 56095f0 into github:main Mar 10, 2026
12 checks passed
Liflex added a commit to Liflex/spec-kit-memory-plus that referenced this pull request Mar 10, 2026
fix: use quiet checkout to avoid exception on git checkout (github#1792)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants