So I have started to rebase a big branch on my current master (75 commits). I know it will take me a day or so. In the meantime, I need to address some comments on another PR.
How can I suspend my current rebase to amend my PR without re-cloning the repo or copying the folder (these would work of course)? Is this even possible?
-
There is no such git rebase option.Sam Varshavchik– Sam Varshavchik2016年11月21日 13:28:34 +00:00Commented Nov 21, 2016 at 13:28
2 Answers 2
There is no built-in way to "pause" a rebase that I know of, although you can certainly accomplish something like it with enough git finesse.
However, in the case you've described, a much simpler solution is simply to do your rebase in one working directory, and do the other changes you need to do in a different working directory.
To get a new working directory, you can either:
Use a simple
git cloneto get a new working directory (AND a local repository, so you'll need to push/pull your results pack the original working directory).Or, take a look at
git worktree, which can help you manage multiple worktrees using the exact same repository data.
4 Comments
git worktree does the job perfectly! It's not exactly what I wanted, but it is still a lot better than to re-clone a complete repo.git worktree before, but after reading this answer and doing 10 minutes of research... I can't believe I haven't heard of it before! It could have saved me so much stress! Thank you for this question and answer!While this isn't exactly what was wanted (just stopping where you are in the middle of a normal rebase), you can effectively do it by planning ahead when you know you have a large rebase to do. A rebase under the covers is basically creating a new branch at the commit you want to rebase on top of, and then cherry picking the commits in order, and then pointing the original branch to the resulting head.
So say you're on FeatA with 10 commits you want to rebase onto main. Just create and checkout a new branch (say RebaseFeatA) at main's head and start cherry picking from commits on FeatA starting with the oldest of the 10 (can also list multiple commits at once in the cherry pick command). Any time you've finished a cherry pick (resolving any conflicts), you can stop and do anything else. Then just switch back to RebaseFeatA and cherry pick more of the commits from FeatA. Then when you're finished with everything, hard reset FeatA to RebaseFeatA and delete RebaseFeatA.