Skip to content

Fix checking out a branch on in existing repo#2114

Open
heewa wants to merge 1 commit into
saltstack:developfrom
heewa:fix-branch-checkout-in-existing-repo
Open

Fix checking out a branch on in existing repo#2114
heewa wants to merge 1 commit into
saltstack:developfrom
heewa:fix-branch-checkout-in-existing-repo

Conversation

@heewa
Copy link
Copy Markdown

@heewa heewa commented Jun 1, 2026

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

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.

1 participant