Skip to content

fix: stash before fast-forwarding in a worktree - #156

Merged
msiemens merged 1 commit into
msiemens:masterfrom
EclipseTech:master
Oct 15, 2026
Merged

msiemens merged 1 commit into
msiemens:masterfrom
EclipseTech:master

Conversation

@EclipseTech

Copy link
Copy Markdown
Contributor
  • Issue: Fast-forward a branch checked out in a worktree ran git merge --ff-only without stashing, so it failed whenever uncommitted changes touched a file that an upstream commit changed
  • Fix: Stash around the fast-forward too

* Issue: Fast-forward a branch checked out in a worktree ran
`git merge --ff-only` without stashing, so it failed whenever
uncommitted changes touched a file that an upstream commit changed
* Fix: Stash around the fast-forward too
@EclipseTech

Copy link
Copy Markdown
Contributor Author
  • All tests pass
  • New test fails w/o fix
  • I was not able to test in Windows

@EclipseTech

Copy link
Copy Markdown
Contributor Author

How to reproduce bug

Run in an empty directory:

# remote, plus a clone with a worktree for branch "feat"
git init --bare origin.git
git clone origin.git test
cd test
echo "init" > f
git add f && git commit -m 'init'
git push origin
git branch --track feat origin/main
git worktree add ../wt feat
cd ..

# Someone else pushes a change to line 1 of f on feat
git clone origin.git other
cd other
git branch --track feat origin/main
echo 'changes' > f
git commit -am 'upstream' && git push origin main
cd ..

# In the worktree, make an uncommitted edit to line 5 of f
cd wt
echo 'anything' > f

# Run git up
git up

Issue result:

feat    fast-forwarding...
'git merge --ff-only origin/feat' returned exit status 1
error: Your local changes to the following files would be overwritten by merge:
	  f

@msiemens

Copy link
Copy Markdown
Owner

Thanks for finding and fixing this!

@msiemens
msiemens merged commit 35a1918 into msiemens:master Oct 15, 2026
16 checks passed
@msiemens

Copy link
Copy Markdown
Owner

This is now released in v2.6.1. Thanks again!

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