Curso de git #10 - Git reset hard

in #spanish7 years ago (edited)

Hola a todos, espero que se encuentren muy bien! 🤗 🤗

En este nuevo post traemos un comando muy interesante e importante cuando usamos git.

Si lo que queremos es devolvernos a algún punto anterior y no queramos los commits que hayamos hecho desde ese punto, lo que vamos a usar es el comando $ git reset, tiene varias opciones y la primera que vamos a ver es $ git reset --hard commitId

Bueno primero tengo que aclararles que este comando toca usarlo con mucho cuidado, ya que podemos borrar todo nuestros cambios hechos en el proyecto.

$ git reset --hard commitId

Básicamente este comando lo usamos cuando queramos regresar a un punto en el tiempo y ya no queramos los últimos cambios hechos, como vemos en el siguiente ejemplo....

Siguiendo con el proyecto que llevamos desde el post anterior, lo que hice fue agregar tres parrafos diferentes, pero realize un commit diferente cada que agregue uno, esto con el fin de poder explicar este comando.

Como ven en la imagen, ya aparecen registrados 3 commits diferentes a los anteriores, y ahora supongamos que lo que quiero es regresar al commit donde todavía no había ningún parrafo agregado al index.html, entonces lo que debo hacer primero es el identificador del commit al cual quiero regresar, en este caso es el siguiente... c34264070d308e785f3dd482d90dbac76cac07de

Esto indica que borraremos todos los cambios hechos apartir de ese commit y posteriores a el, una vez ejecutemos el comando no podremos recuperar los cambios, la única opción es dejar guardados los identificadores de los commits que serán borrados y así podríamos recuperarlos.

Luego de ejecutar el comando, si revisamos nuestro archivo veremos que los parrafos ya no están

y si hacemos un git log veremos que tampoco están registrados los commits anteriores

Esto es todo por ahora, pero debemos tener mucho cuidado al momento de usar el comando.

Saludos! 🤗 🤗

Sort:  

nice post come to my page resteem , upvote my articles and follow me

Este Post ha recibido un Upvote desde la cuenta del King: @dineroconopcion, El cual es un Grupo de Soporte mantenido por 5 personas mas que quieren ayudarte a llegar hacer un Top Autor En Steemit sin tener que invertir en Steem Power. Te Gustaria Ser Parte De Este Projecto?

This Post has been Upvote from the King's Account: @dineroconopcion, It's a Support Group by 5 other people that want to help you be a Top Steemit Author without having to invest into Steem Power. Would You Like To Be Part of this Project?

Congratulations! This post has been upvoted from the communal account, @minnowsupport, by juanpchica from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, theprophet0, someguy123, neoxian, followbtcnews/crimsonclad, and netuoso. The goal is to help Steemit grow by supporting Minnows and creating a social network. Please find us in the Peace, Abundance, and Liberty Network (PALnet) Discord Channel. It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.

This post has received a 0.78 % upvote from @drotto thanks to: @banjo.

This post has been ranked within the top 10 most undervalued posts in the first half of Sep 09. We estimate that this post is undervalued by $76.10 as compared to a scenario in which every voter had an equal say.

See the full rankings and details in The Daily Tribune: Sep 09 - Part I. You can also read about some of our methodology, data analysis and technical details in our initial post.

If you are the author and would prefer not to receive these comments, simply reply "Stop" to this comment.

Coin Marketplace

STEEM 0.17
TRX 0.15
JST 0.028
BTC 57651.10
ETH 2377.43
USDT 1.00
SBD 2.42