| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Snapshot tracking refs before fetch so rebase and sync can distinguish remote rewrites from local work. Adopt only correctly stacked, same-order range-diff-equivalent commits, and stop safely when both sides changed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 30bcbf2a-5ef1-4bdb-a0fc-618294ae8ded
There was a problem hiding this comment.
Adds safe adoption of equivalent server-rebased stack branches.
Changes:
| File | Description |
|---|---|
| cmd/utils.go | Implements snapshotting and remote-tip adoption. |
| cmd/utils_test.go | Tests adoption and rollback scenarios. |
| cmd/rebase.go | Adopts remote rewrites during rebase. |
| cmd/rebase_test.go | Adds end-to-end rebase and sync coverage. |
| cmd/sync.go | Integrates adoption into synchronization. |
| internal/git/git.go | Exposes range equivalence checking. |
| internal/git/gitops.go | Implements git range-diff validation. |
| internal/git/gitops_test.go | Tests equivalence, ordering, and merges. |
| internal/git/mock_ops.go | Adds range-diff mock support. |
| README.md | Documents adoption behavior. |
| docs/src/content/docs/reference/cli.md | Updates CLI reference. |
| docs/src/content/docs/guides/ui.md | Documents server-rebase workflow. |
| skills/gh-stack/SKILL.md | Updates agent command guidance. |
cmd/utils.go:998
if update.branch == currentBranch {
updateErr = git.ResetHard(update.remoteRef)
} else {
updateErr = git.UpdateBranchRef(update.branch, update.remoteSHA)
}
cmd/utils.go:1005
if previous.branch == currentBranch {
_ = git.ResetHard(previous.localSHA)
} else {
_ = git.UpdateBranchRef(previous.branch, previous.localSHA)
Sorry, something went wrong.
Only require a clean worktree when adopting the checked-out branch with reset --hard. Non-current branch updates remain safe with unrelated working-tree changes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 30bcbf2a-5ef1-4bdb-a0fc-618294ae8ded
Recover the previous remote tip from branch reflogs when an earlier fetch already advanced the tracking ref. Adopt equivalent server rebases while stopping sync before it overwrites non-equivalent remote commits, without blocking local-only rewrites.
| Back | FazBrowse Home | New Git URL |
After a stack was rebased on GitHub, gh stack rebase and gh stack sync fetched the rewritten branch tips but would not adopt them because the local branches had diverged from their remote-tracking refs. The commands then tried to rebase or push the stale local branches, often failing even though the server-side rebase had completed successfully.
This change snapshots branch tips before fetching and adopts a server-side rewrite only when the local branch was unchanged, the remote stack is still properly ordered, and git range-diff confirms the same commits in the same order. If both sides changed, commits differ, or the history contains merges, the command stops instead of overwriting either side.
Both rebase and sync now update local branches and stack metadata directly when a safe equivalent server rewrite is detected.
Testing
Stack created with GitHub Stacks CLI • Give Feedback 💬