Will reverting using git reflog mess with history on other branches?

53 Views Asked by At

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

1

There are 1 best solutions below

0
Inigo On

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).