docs: Add Force checkout behavior change to v5-to-v6 migration guide by AriehSchneier · Pull Request #7 · go-git/docs · GitHub
Skip to content

docs: Add Force checkout behavior change to v5-to-v6 migration guide#7

Open
AriehSchneier wants to merge 1 commit intogo-git:mainfrom
AriehSchneier:add-force-checkout-migration-note
Open

docs: Add Force checkout behavior change to v5-to-v6 migration guide#7
AriehSchneier wants to merge 1 commit intogo-git:mainfrom
AriehSchneier:add-force-checkout-migration-note

Conversation

@AriehSchneier
Copy link
Copy Markdown
Contributor

Documents the breaking behavior change in v6 where Checkout with Force: true no longer deletes untracked files, matching git CLI behavior.

Summary

In v5, Worktree.Checkout(&git.CheckoutOptions{Force: true}) would incorrectly delete untracked files from the working directory. This was a bug that has been fixed in v6 via PR go-git/go-git#1903 to match git's actual behavior where --force only resets tracked files.

Changes

  • Added new section 9 documenting the Force checkout behavior change (marked as ✅ Merged)
  • Added checklist item for users to review their Force checkout usage
  • Renumbered all subsequent sections (9→10, 10→11, etc.)

Migration impact

Users who relied on the old behavior need to explicitly call Worktree.Clean() after checkout to remove untracked files.

References

Documents the breaking behavior change in v6 where Checkout with Force: true
no longer deletes untracked files, matching git CLI behavior.

In v5, Force: true would incorrectly delete untracked files from the working
directory. This was fixed in v6 via PR #1903 to match git's actual behavior
where --force only resets tracked files.

Users who relied on the old behavior need to explicitly call Worktree.Clean()
to remove untracked files.

Related: go-git/go-git#1903, go-git/go-git#796, go-git/go-git#1719

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Arieh Schneier <15041913+AriehSchneier@users.noreply.github.com>
@AriehSchneier AriehSchneier requested a review from pjbgf April 6, 2026 08:16
Copy link
Copy Markdown
Member

@pjbgf pjbgf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AriehSchneier thanks for proposing this change. I'm holding the merge until we add Worktree.Clean() to go-git.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worktree.Clean() does not exist yet. Let's merge this once that new func is created.

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.

2 participants