Return to previous commit on the same branch both local and on github

1

My question is this, I have the following commit:

4e3cb77 cambio local
7978945 despues de revertir el cambio de hensel
60e65f9 actualizacion
8397e64 Update prueba.txt
c9bd0fb primer cambio online
39c7cc0 Base de la prueba, archivo inicial local prueba

What is the process to follow to return to a particular commit (the one I want) both locally and on github.com staying in the same branch? So far I can only do it in the following way:

Once I see the log I do a git checkout + the committee I want to go to and this message comes out:

  

You are in 'detached HEAD' state. You can look around, make   experimental changes and commit them, and you can discard any commits   you make in this state without impacting any branches by performing   another checkout If you want to create a new branch to retain commits   you create, you may do so (now or later) by using -b with the checkout   command again. Example: git checkout -b

     

HEAD is now at 39c7cc0 ... Test base, local initial file test

That's where I'm forced to create a new branch with:

git checkout -b rama
git push --set-upstream origin rama

However, in this way, despite creating an additional branch, the commits that were after returning to that commit are also lost, so if I have 10 commits and returned to commit 7, commits 8/9/10 do not see the commit. log of the new branch and I do not want that. I do not know if I was clear enough any doubt please indicate me.

    
asked by Julio Angel Mejia Tejada 18.10.2018 в 04:08
source

1 answer

0

The correct way to do it is to use the command git revert , because it keeps a history of what happened in that branch (as a log).

In this way, the git revert 4e3cb77 command will modify your local copy by reversing the changes you made to commit 4e3cb77 "cambio local" . If you want to restore the branch to a specific point, you can reverse multiple commits until you reach the desired point.

    
answered by 18.10.2018 / 04:28
source