Add a way to sync a stack from the remote without pushing
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
Research direction
Start with the existing gh stack sync command and trace how it fetches, rebases, and pushes stack branches. Compare that flow with the documented git fetch --all --prune and branch-reset sequence. Done means a sync mode or command updates local stack branches from their remotes without rebasing, pushing, or creating duplicate commits.
Written by the indexing model from the issue text.
Description
When a stack has been restacked and force-pushed from elsewhere either by a collaborator, or the rebase option on gh webapp my local branches are left with the pre-rebase SHAs. With stack view every branch shows as ahead N, behind N against its remote, but the "ahead" commits are just stale copies of work that's already upstream under different hashes.
What I want in that situation is "make my local stack match the remote". as far as I am aware gh stack sync is close to doing this, but it always pushes (--force-with-lease --atomic), which is the opposite direction, and there's no flag to stop it.
It also doesn't just no-op, it rebases those stale local commits onto the updated parents, which replays commits that are already upstream. I ended up with empty duplicate commits on a branch that way, including one that kept its original co-authors on a no-op.
So what I end up doing when I want my local to match the remote stack is:
git fetch --all --prune
for every stack branch git branch -f "$branch" "origin/$b"
I think a good solution would be either a flag on sync (--no-push, or a --reset/--from-remote mode) or a separate
command, that fetches and points each local stack branch at its remote without rebasing or pushing anything. You could even have sync detect this case where local is ahead only by commits whose patch-id already exists upstream rather than directly with a flag.
- Dominant language
- Go
- Stars
- 1.5k
- Forks
- 73
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 7
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from github/gh-stack
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
feature request topic: cli - general
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
feature request topic: auto-merge
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
bug topic: docs
Difficulty 1/5 Under an hour Newbie friendliness 68/100
Similar issues
-
feature-request helm
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
gravitational/teleport#69785 ·
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
crossplane/crossplane#7859 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100