1

The scenario: I have a couple branches going. One of them's pretty old, so I'm rebasing it on master. Half-way through resolving the numerous conflicts, I realize there's something else I need to get done.

Now I'd like some way to preserve these changes, while I switch to another branch to finish the new task. Once I'm done with that, I want to come back to the branch I was rebasing and continue.

What's the neatest way of doing this? The best I can think of is to stash, and then reapply every time I'm ready to resume. But I'm not a fan of this since I'd have to do it each time I "pause", and it could get easily lost in my stash stack, making me track it each time.

notablytipsy
  • 387
  • 1
  • 4
  • 19

1 Answers1

3

If you can, try and create a second working tree, one where you can switch branches freely.

Your current working tree should be kept solely reserved for your current rebase, with its lengthy conflict resolution.

See "Multiple working directories with Git?" and the git worktree command, to create that second local working tree.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    If you don't have `git worktree`, making a second clone is a useful approximation. But probably better just to install a newer Git. :-) – torek May 21 '20 at 01:57
  • Was going to suggest a worktree if nobody had brought it up. – eftshift0 May 21 '20 at 02:18
  • I'll give that a try! Thanks! – notablytipsy May 21 '20 at 17:29
  • Goddamn perfect. – notablytipsy May 21 '20 at 17:40
  • Well, _nearly_. It would be nice to have it somehow work within the same directory so that my virtualenv/rsync/etc could function without issue, but it does solve the main issue – notablytipsy May 21 '20 at 18:26
  • 1
    @notablytipsy I agree, this is one drawback of that approach. A possible way to alleviate said drawback would be to have a symlink to one or the other working tree folder, depending on your current task, in order to maintain the *same* path (for your IDE), while maintaining the ability to switch working trees (by re-routing the symlink to the right folder) – VonC May 21 '20 at 19:38