git - Can I reset to any commit in middle of a rebase? -


i started interactive rebase edit few commits. while went kind of messed last 2 commits (i accidentally squashed them). hoping if reset commit before editing last 2 commits , still in middle of rebase started. can see steps in reflog if reset hard of steps can go commit not rebase session. there way or alternatives if want edit last 2 commits (because before fine)?

the easiest way find head commit of branch before rebase started in reflog...

git reflog 

and reset current branch (with usual caveats being absolutely sure before reseting --hard option).

# suppose old commit head@{5} in ref log git reset --hard head@{5} 

you can check history of candidate old head doing git log head@{5} .

if you've enabled per branch reflogs should able git reflog branchname@{1} rebase detaches branch head before reattaching final head. double check this, though haven't verified recently. can adding:

[user]     logallrefupdates=true 

to in safer side make backup first: git tag backup. can return if goes wrong: git reset --hard backup

i found link helpful.

thanks.


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -