git - undo commit in merged branch -


commit graph (how is):

* hash1 - (head) last commit * hash2 - merge commit |\ | * hash3 - last branch commit should undone | * hash4 - commit should have been merged instead of hash3 | * hash5 - first branch commit * | hash6 - commit on master after branch creation |/ * hash7 - before trouble began ... 

commit hash4 last working commit, on different branch (not master). hash3 bad commit breaks project, merged master (hash2). hash1 unsuccessful try fix. how can revert hash4 , merge hash6 working project again?

commit graph (how should be):

* hash2 - merge commit |\ | * hash4 - commit should have been merged instead of hash3 | * hash5 - first branch commit * | hash6 - commit on master after branch creation |/ * hash7 - before trouble began ... 

you have several options:

git reflog

reflog store history of every change made head. can checkout repository given commit (detached head), create branch point , stuff.

for example:

git reflog .. find out head@{n} of desired commit git checkout head@{n} git checkout -b my_new_branch // @ point have new branch **head4** last commit 

git revert

git revert lets "rollback" = revert commit(s) wish discard.

git revert sha1 sha1 sha1 sha1  git revert head3 

this create commit undo of changes made in head3


Comments

Popular posts from this blog

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - JavaScript + Thymeleaf - select onchange -

node.js - Using Node without global install -