Sorry I'm a little new to this. I'm playing aroun...
# how-do-i
c
Sorry I'm a little new to this. I'm playing around with Graphite and I'd quite like to turn some existing feature branches into a stack (if that's possible). We have a
main
branch, then we have a
dev
branch. I have a
dev/feature-1
branch which was made from the
dev
branch. I then have additional work in
dev/feature-2
and
dev/feature-3
. Essentially
dev > dev/feature-1 > dev/feature-2 > dev/feature-3
At the moment I have three PRs open, one to merge
dev/feature-3
into
dev/feature-2
another to merge
dev/feature-2
into
dev-feature-1
and then finally one to merge
dev/feature-1
into
dev
. Is it possible to create a stack from these three branches? I've tried a few things that I thought were correct but I'm a bit nervous. The existing PRs that are open don't matter. I'm happy to close them and let Graphite recreate them. I guess I'm mostly confused about the right course of action when the work has essentially already been done. But there is more work to do so stacking what we have already makes a lot of sense, I think.
p
(If applicable) To help us more clearly understand what you're trying to do, please provide additional details about: - Screenshots / debug logs / list of commands you've tried to run so far - Your workflow - Current state
👍 1
c
I'm pretty sure what I've said encapsulates everything as it is but happy to provide more info if anything specific.
p
hey Chris, the first thing to do while navigated to the repo in your terminal is to run
gt init
so you can initialize Graphite in this repository by selecting a trunk branch (i.e.
dev
). Then you can checkout the
dev/feature-3
branch and run gt track to start tracking it with Graphite and recursively track the rest of the stack of branches by specifying each branch’s parent interactively. Once done you should be able to run
gt ls
to visualize your stack.
c
Thanks @Gareth Brickman. Is the parent for
dev/feature-3
supposed to be
dev/feature-2
or is it supposed to be
dev
?
p
dev/feature-2
. Then its parent is
dev/feature-1
and its parent is trunk
dev
.
c
Ahh I think the history of this is all messed up. I don't think
feature-3
is up to date with
feature-2
. I suspect I just need to do some rebases and get it to where it should be.
Hi Gary I think we've made some progress 🙂
Copy code
gt ls
◉  dev/feature-3
◯  dev/feature-2
◯  dev/feature-1 (needs restack)
◯  dev
I'm not sure what
needs restack
means. I think I need to do a
gt submit
at some point, but I'm not sure, especially because I have PRs open for them (which were created some time ago manually through GitHub)
p
great, that looks good! You can run
gt restack
to ensure each branch in the current stack has its parent in its Git commit history, rebasing if necessary. If conflicts are encountered, you will be prompted to resolve them via an interactive Git rebase.