You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hasnat Anjum Haz edited this page Mar 29, 2022
·
1 revision
In a git branch, we may have some commits rebased on top on another branch. And after some stories, the branch on which we rebased on can get stale. And we want to undo rebase.
Let's get our hands dirty!
gitreflog
The ref logs are listed as rows of commit sha, head tips etc.
After you do reflog, copy the HEAD@{x} when HEAD@{x} points to the head of the stale branch on top of which you rebased your current commits.
Now we will reset current head to HEAD@{x}. Before that, if there is any change we want to commit, please commit them, so that we don't lose them after resetting head. After resetting head, we can apply required commits using cherry-pick.
So, let's say we want to reset to HEAD@{21} and want to apply 2 commits with sha 123 and 456, where 456 should be on top of 123-