![github desktop revert to previous commit github desktop revert to previous commit](https://raw.githubusercontent.com/vhanla/ExplorerRestarter/master/.gitassets/snap01.png)
In case you wanted to learn more about the commands described in this post you can check out the official git reference: In both cases you will still need to update the submodules after that by running: git submodule update In case you used git reset, you need to use: git pull
![github desktop revert to previous commit github desktop revert to previous commit](https://www.it-ouji.com/wp-content/uploads/2020/05/git_2-1-1024x449.png)
In case you used git checkout, you need to use it again like in the following command (assuming you are in the branch master): git checkout master If you want to go back to the most recent version of your project you have to follow 2 different procedures based on what command you before. To synchronise all your submodules to the version they were at the time of the commit you went back to all you need to do is running a single command: git submodule update Going back to the most recent commit Synchronise the submodulesĪfter checking out or resetting the working directory of your project you will probably notice that the directories containing a submodule are marked as “ modified” and that they have not been altered (local files are unchanged). If you wanted to know more about the difference between git reset and git checkout I would recommend to read Reset Demystified on the official git blog. Furthermore it won’t alter the current branch you are into. The main difference between them is that checkout is generally safer as it won’t overwrite local changes in the working directory. Now that you know the hash of the commit you want to go to you can use one of the following 2 commands: git checkout HASH Which will give you a compact list of all the commits and the short version of the SHA-1 hash. If you want to use the command line I would recommend to use the following options with the log command: git log -abbrev-commit -pretty=oneline To do that all you need it the SHA-1 hash of the commit which you can easily find checking the log with the command: git log Sometimes when working on a git repository you want to go back to a specific commit (revision) to have a snapshot of your project at a specific time. Go to a particular commit of a git repository In this short guide I will show you how to do all that. This document is inspired by - Thank you.If you want to go to a particular commit of a git repository with submodules you can use 2 git commands: reset or checkout. You will also need to synchronise the submodules after the working directory has been altered as that doesn’t happen automatically. If you have the master branch checked out locally, you can also do it in two simpler steps: First reset the branch to the parent of the current commit, then force-push it to the remote. Where git interprets x^ as the parent of x and + as a forced non-fastforward push. Translated to git terminology, we want to force the master branch of the origin remote repository to the parent of dd61ab32: git push origin +dd61ab32^:master
![github desktop revert to previous commit github desktop revert to previous commit](https://omnis.ci/images/guides/sharing-omnis-libraries-on-github/initial_commit.png)
Let's say we have a remote origin with branch master that currently points to commit dd61ab32.
![github desktop revert to previous commit github desktop revert to previous commit](https://joeyklee.github.io/friendly-github-intro/assets/images-slides/install.png)
git revert Ībout History Rewriting Delete the last commitĭeleting the last commit is the easiest case. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Sometimes you may want to undo a whole commit with all changes.