0

I messed up on a git rebase, but I've done a bunch of work in other branches since then and now I'm coming back to this. If I revert to a previous version with reflog, will that undo my other changes?

ex curr

i messed with other branch

i miseed with other branch 2

i messed up my rebase

rebase continue

rebase started <-- I want to go back here

Brandon-Perry
  • 366
  • 4
  • 18
  • 1
    As long as (1) your working directory is clean (2) you have committed everything somewhere then you can reset using the reflog to your hearts content. – Guildenstern Apr 27 '23 at 22:50

1 Answers1

1

A branch is really just a pointer (ref) to a commit, and every commit has a pointer to a parent commit (or multiple parents if a merge commit). Reverting to a previous version is simply moving the pointer. That doesn't have any impact on your other branches because they are also just pointers. When you make any kind of commit, even when you rebase or rewrite history, it is all done via new commits. Old ones are never touched or modified, and they will only get garbage collected if they are not reachable by any ref heads (branch pointers) for a long time (weeks if not months).

Inigo
  • 12,186
  • 5
  • 41
  • 70