lunes, 30 de noviembre de 2020

GIT Demystifying part 8, checkout vs reset

 GIT Demystifying part 8, checkout vs reset

Checkout is simplest as reset. first create a two commits scenario, then do checkout, return state with checkout , and then apply reset.




Procedure on command line

creation of the two commits and branches only for references for reset and checkout.



Till now, here are two commits with two files each.

The checkout to commit 01 (branch principal) only update de State (Working directory, Stage) from commit 2.


And return to develop or commit 2, to apply the reset command.


With Reset, the files are unstaged, with the possibility of add or restore, add apply the commit 2 to commit 1, this is file1:v2 -> file1:v1 = file1:v2, and restore file2:v1 of commit 1 remains intact.

One importan thing is that now branch develop point also to the same as principal.

This not happen with checkout.

Now, How remove de develop branch that point to the same as principal branch? with

git branch -d develop

to do this in the example, we move to de commit 2 with git checkout 3cbd8, and the delete the develop branch.



As HEAD is in commit 2, we can name this again as develop with git branch develop.

eot

No hay comentarios:

Publicar un comentario