Fix: Resolve git checkout error in fetch-sfs-workflow#55
Merged
Conversation
Fixed a bug where `git checkout` failed with "Your local changes would be overwritten" error. Problem: - The workflow was running `git add` before checking out the target branch - When the branch existed remotely, `git checkout` would fail because staged changes would be lost Solution: - Check for changes WITHOUT staging them first (using `git diff --quiet` and `git ls-files --others`) - Checkout the target branch BEFORE running `git add` - Stage files only after being on the correct branch This ensures the workflow can successfully checkout and merge with existing branches. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
fetch-sfs-workflowwas failing with this error:Root Cause
The workflow was staging changes with
git addbefore attempting to checkout the target branch. When the branch existed remotely,git checkoutwould fail because it would overwrite the staged changes.Solution
This PR fixes the issue by:
git diff --quietandgit ls-files --others)git addTesting
The workflow should now successfully:
data/md-markers/anddata/sfs_json/workflow-artifact-databranch without conflictsRelated
Fixes the error seen in: https://github.com/se-lex/sfs-processor/actions/runs/20804696587/job/59756444556
🤖 Generated with Claude Code