Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

With git, how to save/pause a ongoing big rebase to do something else, then go back to it?

Tags:

git

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?

like image 620
autra Avatar asked Nov 21 '16 12:11

autra


People also ask

How do I save rebase changes in git?

Press the Esc key, type :wq! and press Enter key to save and exit the document.

How do I terminate an ongoing rebase?

You can run git rebase --abort to completely undo the rebase. Git will return you to your branch's state as it was before git rebase was called. You can run git rebase --skip to completely skip the commit.

How do you rebase without going through each commit?

If you don't want rebase to stop at each commit if you get any merge conflicts and want it to stop only once during the rebase process, you can squash all the commits into one in your fix/align-div-vertically branch by squashing them using interactive rebase before rebasing with the master.

Can rebase be undone?

So for example, if you rebase featureA branch onto your master branch, but you don't like the result of the rebase, then you can simply do git reset --hard featureA@{1} to reset the branch back to exactly where it was before you did the rebase.


1 Answers

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 clone to 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.

like image 74
wjl Avatar answered Sep 28 '22 01:09

wjl