Git tutorial #10 - Git reset hard

in #technology7 years ago

Hello everybody! 🤗 🤗

In this new post we bring a very interesting and important command when we use git.

If we want to return to some previous point and do not want the commits we have done from that point, what we are going to use is the $ git reset command, it has several options and the first one we are going to see is $ git reset --hard commitId

Well first I have to clarify to them that this command touches to use it very carefully, since we can erase all our changes made in the project.

$ git reset --hard commitId

Basically this command we use when we want to return to a point in time and we do not want the latest changes made, as we see in the following example ....

Following with the project that we carried from the previous post, what I did was to add three different paragraphs, but make a different commit every one that adds one, this in order to be able to explain this command.

As you see in the image, 3 commits different from the previous ones are already registered, and now suppose that what I want is to return to the commit where there was still no paragraph added to index.html, so what I should do first is the commit identifier to which I want to return, in this case it is the following ... c34264070d308e785f3dd482d90dbac76cac07de

This indicates that we will delete all the changes made after that commit and after, once we execute the command we will not be able to recover the changes, the only option is to leave the identifiers of the commits that will be deleted and we could recover them.

After executing the command, if we check our file we will see that the paragraphs are no longer

and if we do a git log we will see that the previous commits are not registered either

This is all for now, but we must be very careful when using the command.

regards! 🤗 🤗

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?

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

Coin Marketplace

STEEM 0.17
TRX 0.13
JST 0.028
BTC 59705.02
ETH 2619.44
USDT 1.00
SBD 2.39