This happens, I have two main branches: master and development.
So far master had one commit (the one at the beginning of the project) and my development branch had several commits.
My flow is this: I create a branch every time I am going to make a change and when I finish I do a merge to development
$ git checkout desarrollo && git merge rama-de-cambio
Accidentally merged into master using
$ git checkout master && git merge rama-de-cambio
What is the way to return master to its original state and be able to merge it to my development branch?
The short version:
This would be the procedure in detail:
If for some reason we need to revert the files in our Git repository to a previous push, we need to follow the steps below.
1. Get hash ids of the latest commits. In necessary Identify the hash id of the commit to which we want to return, with the following command we will see the last 10 ids:
30ace57438659c6a715db441ffc6751f385db667 484121a5ed21e8b842ffe61783fde059103185b3 996ee5f0aabd18d14a73e0181780dcc9191337f4 2b0ea751d69c84b909b3011ba5de865125d209b2 944385404a3468fe6665be2d8cf1a71a5c995196 6b832d19e44d298d60c99a382f9e7e282c9c16f2 fad00716beff7b48890f0a96d82780bea685f39e 4339ddc09724d93bac456221a0c369c3d5a62c89 cf9a82f09bb799c2449854ba7d33ddf2cfff3b84 adf47c09992f147ab2b631713cc8dd612f21e83d
2. Return to the desired commit. When we have identified the commit to which we want to return our repository, we must execute a command similar to the following.
HEAD is now at 484121a
3. Push the changes to the repository. Now we need to push the changes to the repository with the following command.
4. Update repositories. If we have any clones of the project elsewhere, we must checkout the commit we wish to return to by running the following command.
I hope it will be you useful.
original source:
http://www.7sabores.com/blog/how-to-revert-a-push-git
what you have to do is locate the commit saved in the change-branch before doing the merge and then