Hi, I'm increasingly having issue where Graphite C...
# how-do-i
j
Hi, I'm increasingly having issue where Graphite CLI tells me my branch can't be restacked cleanly because of conflicts when I use the CLI checkout command like
gt get "bugfix/..." --unfrozen
or when I use
gt get
followed by
gt unfreeze
then
gt sync
Copy code
fryej@GRP:~/Upload$ gt sync
:evergreen_tree: Fetching branches from remote...
main is up to date.

:arrows_counterclockwise: Syncing branches...
Branch bugfix/... is up to date with remote, but the current remote version was not pushed with Graphite.

:pancakes: Restacking branches...

WARNING: bugfix/... could not be restacked cleanly.

Please resolve conflicts in the current stack with gt restack.
If I check on app.graphite.com or via GitHub, there are no conflicts. One time
gt repo init --reset
and then checking out the branch normally via
git checkout
then
gt track
helped fix the isuse but that's not working for me now. Any idea what I'm doing wrong? Can this happen if another dev doesn't submit changes with graphite CLI?
j
Yes, a push that didn't go through the Graphite CLI can cause this. The disagreement between the two is expected: GitHub checks for conflicts by test-merging your branch into 
main
, but 
gt
 restacks by rebasing your commits onto it. A rebase replays commits one at a time and can conflict where a single merge wouldn't, so a clean PR page doesn't mean a clean restack. Usually these are real and you just work through them once:
Copy code
gt restack
# resolve, git add the files, then:
gt continue
If the conflicts are in files you never touched, or it looks like it's replaying way more commits than your PR actually has, that's a different problem. When the remote version didn't come from 
gt submit
, Graphite doesn't refresh where it thinks your branch starts, so it can replay from a stale point. 
gt track -p main
 resets just that, without touching any commits. Either way, could you run 
gt --debug sync
 and send me the 
Rebasing N commits from ...
 line?
j
That's exactly what happened, the dev said they we're just doing normal git merges. I had him go through the
gt restack
and
gt submit
but when I
gt get
his branch it's still trying to get me to restack as well?
Rebasing 33 commits from ...
j
gt
 asks for a restack whenever the branch isn't sitting on your current local 
main
, and 
main
 moves constantly, so it re-arms itself no matter what he does on his end. The conflicts are the real thing. A restack drops merge commits, so if that branch has been kept current with 
git merge main
, the conflicts he resolved inside those merges get thrown away and resurface one commit at a time. GitHub doesn't show them because it merges the finished branch in one shot. To unblock now: 
gt get "bugfix/..." --no-restack
Can you send these two from that branch?
Copy code
git rev-list --count main..bugfix/...
git log --oneline --merges main..bugfix/...
If merges show up, having him 
gt squash
 the branch should stop the conflicts, since one commit replays the same way GitHub merges it. It force-pushes, so worth warning reviewers first.
j
Sorry, forgot about this. I ended up merging the PR and told dev we need to use
gt
commands going forward 😅. This is good to know though!