I am working with a branch B
and I have the branch Master
. I just finished my modifications and I wanted to add them to the Master, but instead of doing this I made a merge branch 'Master' into 'B'
(I put it in English because I don't know how to translate it and because I'm using gitHubDesktop
).
I did the commit without solving the problems thinking that I could go back to the previous one and everything would be fine but now I have a lot of conflicts in my source code. Try to go back to the previous commit, to the merge, but the changes remain. How can I go back to this commit without the Merge I did from the master?
You can see all the states with the command
git reflog
the result will be a list of states with the first column being the code for its respective state.Then with the command
git reset --hard {poner codigo de la lista}
you can return to the state you want.For example, to return to the HEAD@{2} state, the command would be:
Note : to know which state to go to, you can base yourself on the comment in the last column
Another alternative solution would be to save in a draft, cleaning the current branch with the command
git stash save
If it is your case that you merged for example from your development branch in qa but you want to remove that merge and leave it if those changes you can use
with that you can either stash or checkout the modified files for or do a git reset --hard plus the code from the last commit you want to return to.