docs: Add Force checkout behavior change to v5-to-v6 migration guide#7
Open
AriehSchneier wants to merge 1 commit intogo-git:mainfrom
Open
docs: Add Force checkout behavior change to v5-to-v6 migration guide#7AriehSchneier wants to merge 1 commit intogo-git:mainfrom
AriehSchneier wants to merge 1 commit intogo-git:mainfrom
Conversation
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>
pjbgf
reviewed
Apr 6, 2026
Member
pjbgf
left a comment
There was a problem hiding this comment.
@AriehSchneier thanks for proposing this change. I'm holding the merge until we add Worktree.Clean() to go-git.
| - [ ] Update code that implements or embeds `commitgraph.Index` — the interface gained `io.Closer` and new methods | ||
| - [ ] Review any code that constructs `osfs` instances for `Plain*` operations — `BoundOS` is now the default | ||
| - [ ] Remove any validation that requires `refs/` prefix on `branch.*.merge` config values | ||
| - [ ] Update code that relied on `Force: true` to remove untracked files — use `Worktree.Clean()` explicitly instead |
Member
There was a problem hiding this comment.
Worktree.Clean() does not exist yet. Let's merge this once that new func is created.
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.
Documents the breaking behavior change in v6 where
CheckoutwithForce: trueno 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--forceonly resets tracked files.Changes
Migration impact
Users who relied on the old behavior need to explicitly call
Worktree.Clean()after checkout to remove untracked files.References