Skip to content

Fix: Resolve git checkout error in fetch-sfs-workflow#55

Merged
marcarl merged 1 commit intomainfrom
fix/workflow-git-checkout-staged-changes
Jan 8, 2026
Merged

Fix: Resolve git checkout error in fetch-sfs-workflow#55
marcarl merged 1 commit intomainfrom
fix/workflow-git-checkout-staged-changes

Conversation

@marcarl
Copy link
Copy Markdown
Collaborator

@marcarl marcarl commented Jan 8, 2026

Problem

The fetch-sfs-workflow was failing with this error:

error: Your local changes to the following files would be overwritten by checkout:
	data/md-markers/...
Aborting

Root Cause

The workflow was staging changes with git add before attempting to checkout the target branch. When the branch existed remotely, git checkout would fail because it would overwrite the staged changes.

Solution

This PR fixes the issue by:

  1. Checking for changes without staging them first (using git diff --quiet and git ls-files --others)
  2. Checking out the target branch before running git add
  3. Staging files only after being on the correct branch

Testing

The workflow should now successfully:

  • Check for changes in data/md-markers/ and data/sfs_json/
  • Checkout existing workflow-artifact-data branch without conflicts
  • Stage and commit changes on the correct branch

Related

Fixes the error seen in: https://github.com/se-lex/sfs-processor/actions/runs/20804696587/job/59756444556

🤖 Generated with Claude Code

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>
@marcarl marcarl merged commit 608e809 into main Jan 8, 2026
5 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.

1 participant