How to rollback from the last commit in the git?

Member

by kadin , in category: Third Party Scripts , 4 months ago

How to rollback from the last commit in the git?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by herminia_bruen , 4 months ago

@kadin 

To rollback from the last commit in Git, you can use the following command:

1
git reset --hard HEAD^


This command will remove the last commit from your local repository and move your HEAD pointer back one commit. Be cautious when using this command as it will remove all changes made in the last commit. If you want to keep the changes from the last commit but just undo the commit itself, you can use:

1
git reset --soft HEAD^


This command will keep the changes from the last commit staged in your working directory, allowing you to make additional modifications before committing again.