Skip to content

[v6] No longer switch branches locally and drop create_branch, skip_fetch and skip_checkout options#314

Merged
stefanzweifel merged 14 commits intov6-nextfrom
v6/remove-local-branch-switch
Feb 5, 2025
Merged

[v6] No longer switch branches locally and drop create_branch, skip_fetch and skip_checkout options#314
stefanzweifel merged 14 commits intov6-nextfrom
v6/remove-local-branch-switch

Conversation

@stefanzweifel
Copy link
Copy Markdown
Owner

@stefanzweifel stefanzweifel commented Dec 20, 2023

This pull request tackles a long standing issue with this action: how the action works with branches internally.

Since forever, the action will switch branches locally, if a branch name is provided through the branch-option.
This leads to a slew of problems, when users write workflows, where the repo is checked out using the default branch (main) but the changes are then pushed to a different branch (example-branch-1) (Example: #301).

This annoyed me for a long time. There's no need to check out the given branch locally. A local branch does not have to align with the remote branch in order to push a commit to said remote branch.
We can target the right target branch in the git-push command.


This PR changes this behaviour by removing the _switch_to_branch function completely.
By removing the function, the action also no longer runs git-fetch.

The test suite of the action has been adjusted accordingly. Some tests have been removed. Some tests have been rewritten, as removing the _switch_to_branch function changed the behaviour of the action in certain cases. See "Breaking Changes" section for details.

As this is a breaking change, this change will be released in an upcoming major release (v6) of this Action.


Why I added the current behaviour of switching branches locally is a mistery to me. I probably wrote the code this way, as I personally always mirror the branch names in my local repository with my remote repository. (I would work on a branch called feature-x and push that to origin/feature-x and not origin/development)

Potential Issues

If a user checks out a repository on it's default branch (main), makes changes to the repo and pushes the changes to remote branch example which already exists on remote and has newer commits, the action will fail to push to remote with an error message like this:

Updates were rejected because the remote contains work that you do
not have locally. This is usually caused by another repository pushing
to the same ref. You may want to first integrate the remote changes
(e.g., 'git pull ...') before pushing again.

The solution here will still be, that the user has to solve these "out-of-sync" issues on their own by adding a git-pull or git-rebase step in their workflows.

Breaking Changes

The following options have been removed from git-auto-commit and can be removed from your workflows.

  • create_branch (git-auto-commit no longer switches branches locally during a workflow run)
  • skip_fetch
  • skip_checkout

Related Issues

TODOs

  • Make tests green again
  • Write UPGRADE.md
  • Document breaking changes
  • Update Docs

@stefanzweifel stefanzweifel self-assigned this Dec 20, 2023
@ashleycaselli
Copy link
Copy Markdown

@stefanzweifel are you planning to release v6 anytime soon?

@stefanzweifel
Copy link
Copy Markdown
Owner Author

@ashleycaselli I think I will tag a new release in February/March 2025.

Do the mentioned options mentioned here cause any problems for you right now?

@stefanzweifel stefanzweifel changed the base branch from master to v6-next February 5, 2025 12:58
@stefanzweifel stefanzweifel marked this pull request as ready for review February 5, 2025 13:00
@stefanzweifel stefanzweifel merged commit 9fa4cb9 into v6-next Feb 5, 2025
2 checks passed
@stefanzweifel stefanzweifel deleted the v6/remove-local-branch-switch branch February 5, 2025 15:01
@stefanzweifel stefanzweifel mentioned this pull request Jun 1, 2025
@cforiguar
Copy link
Copy Markdown

reame.md still uses v5 an doesn't reflect yaml changes needed to be done for the action to work

@stefanzweifel
Copy link
Copy Markdown
Owner Author

stefanzweifel commented Jun 13, 2025

@cforiguar thanks! I will update the README asap.
Not sure how this slipped my mind.

Edit: Updated the README in f9017b2. The 3 input options had been removed previously from the README.

If you run into a problem, you have to be more specific than just "doesn't work".

rasben added a commit to danskernesdigitalebibliotek/dpl-cms that referenced this pull request Jul 29, 2025
V6 has removed the `create_branch` option, but apparantly it is not a
problem as the `branch` option now works slightly differently.

stefanzweifel/git-auto-commit-action#314
cavcrosby added a commit to cavcrosby/kubectl that referenced this pull request Oct 11, 2025
This was done because said option was removed as of version 6 of the
git-auto-commit GitHub action. Its removal shouldn't affect anything,
as the local branch within the job will just be named gh-pages
remotely. The GitHub pull request for this change is here:
stefanzweifel/git-auto-commit-action#314.
crookm pushed a commit to interflare/orleans-marten that referenced this pull request Mar 23, 2026
…tion to v6 (#30)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [https://enduringtech.dev/actions/commit-action](https://enduringtech.dev/actions/commit-action) | action | major | `v5.2.0` -> `v6.0.1` |

---

### Release Notes

<details>
<summary>actions/commit-action (https://enduringtech.dev/actions/commit-action)</summary>

### [`v6.0.1`](https://enduringtech.dev/actions/commit-action/blob/HEAD/CHANGELOG.md#v601---2025-06-11)

[Compare Source](https://enduringtech.dev/actions/commit-action/compare/v6.0.0...v6.0.1)

##### Fixed

- Disable Check if Repo is in Detached State ([#&#8203;379](stefanzweifel/git-auto-commit-action#379)) [@&#8203;stefanzweifel](https://github.com/@&#8203;stefanzweifel)

### [`v6.0.0`](https://enduringtech.dev/actions/commit-action/blob/HEAD/CHANGELOG.md#v600---2025-06-10)

[Compare Source](https://enduringtech.dev/actions/commit-action/compare/v5.2.0...v6.0.0)

##### Added

- Throw error early if repository is in a detached state ([#&#8203;357](stefanzweifel/git-auto-commit-action#357))

##### Fixed

- Fix PAT instructions with Dependabot ([#&#8203;376](stefanzweifel/git-auto-commit-action#376)) [@&#8203;Dreamsorcerer](https://github.com/@&#8203;Dreamsorcerer)

##### Removed

- Remove support for `create_branch`, `skip_checkout`, `skip_Fetch` ([#&#8203;314](stefanzweifel/git-auto-commit-action#314))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4zOC4yIiwidXBkYXRlZEluVmVyIjoiNDEuMzguMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

Reviewed-on: https://enduringtech.dev/interflare/orleans-marten/pulls/30
Reviewed-by: Matt <mattlcrook@icloud.com>
Co-authored-by: Renovate Bot <renovate.svc@enduringtech.dev>
Co-committed-by: Renovate Bot <renovate.svc@enduringtech.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants