Skip to content

Fix checking out a branch on in existing repo - #2114

Merged
twangboy merged 2 commits into
saltstack:developfrom
heewa:fix-branch-checkout-in-existing-repo
Sep 2, 2026
Merged

Fix checking out a branch on in existing repo#2114
twangboy merged 2 commits into
saltstack:developfrom
heewa:fix-branch-checkout-in-existing-repo

Conversation

@heewa

@heewa heewa commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

In the case where a git repo already exists:

  • if a branch is intended to be checked out, reset to origin/<branch>
    • this mirrors the behavior of the repo not existing on these lines, a little further down
    • it avoids problems stemming from a local branch by that name already existing, which may not even be related, or could have diverged from origin
  • remove the unnecessary code that rebases from origin, since we just directly check it out (which happens after a fetch updates it a few lines up)

What issues does this PR fix or reference?

When a user first runs bootstrap-salt.sh with a branch specified (without a checked out repo) works fine, but sets up HEAD in a detached state to origin/<branch>. Subsequent runs of the bootstrap script fail when it tries to git reset --hard <branch> , with err:

fatal: ambiguous argument '': unknown revision or path not in the working tree.

Previous Behavior

Remove this section if not relevant

New Behavior

Remove this section if not relevant

@twangboy twangboy self-assigned this Jul 9, 2026
Comment thread bootstrap-salt.sh
heewa and others added 2 commits August 31, 2026 13:29
Resolve the checkout target into a dedicated __GIT_CHECKOUT_REV
variable instead of overwriting GIT_REV_ADJ in place, so the
raw revision value stays available and isn't repurposed to mean
two different things within the same function.
@twangboy
twangboy force-pushed the fix-branch-checkout-in-existing-repo branch from 8865736 to c59f15e Compare August 31, 2026 19:29
@twangboy
twangboy merged commit bc5e5d8 into saltstack:develop Sep 2, 2026
241 of 243 checks passed
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.

2 participants