Repository navigation
How do we get remote stash state without rebasing? #560
Replies: 1 comment
|
There's no flag for that today: when You don't need to unstack, though. The local stack only stores branch names, so you can keep it and point each branch at its remote version with plain git: git fetch origin --prune
branches=$(gh stack view --json | jq -r '.branches[] | select(.isMerged | not) | .name')
git switch main # git won't force-move the branch you're on
for b in $branches; do git branch -f "$b" "origin/$b"; done
gh stack top # or git switch <branch>This throws away any local commits on those branches that aren't on the remote, so it's exactly "remote is the source of truth". If your colleagues also added or removed PRs in the stack (not just commits), |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Scenario
In other words, I'd like my local stack and branches to match exactly what's on the remote, with the remote as the sole source of truth.
**Question: ** how do I do that?
What I tried
gh syncI assumed that there would be a command line option in
gh sync, but it forces a rebase onto main and a push (which I don't want).Deleting my local stack and recreating
I've tried recreating stack locally with
But because the branch exists locally, I get only my local state and not the remote state.
Awkward last-resort solution
I guess that the only way to do it is to delete all the branches in the stack from my local repo, then do the steps above, but this feels very awkward.
Is there a better way than this?
All reactions