Let us understand git revert with an example. After REVERT, do not forget to PUSH the code. commit-id is the unique id that represents the commit till where we want our changes to be reverted (alongwith retaining the codes in unwanted commits)Īfter we have executed ' git revert' using the above syntax, the window will show us a summary that we have reverted to a particular commit, and we will need to type :q (colon+q) to close that summary UI. You can't revert back to that commit on the GitHub web site, there is no option to do this action, Instead, you should use command-line or GitHub Desktop as below.git revert indicates that we are reverting our code to a particular previous commit marked by that commit-id.Here is the syntax of using ' git revert' that can be used to undo a commit in git. Only a new reverted commit is placed after all the last commits to which the HEAD will now point. While using git revert, all the previous commits remain intact. There can be instances when we have written codes in a commit(s) and later figure out that commit(s) (or the codes written in that commit(s)) is not helpful.īut we want to retain that unwanted commit(s) in the commit history and work back on a commit before that. git revert doesn't move ref pointers to the commit that we're reverting, which is in contrast to other ‘undo' commands, such as git checkout and git reset. Once the IT team chooses a code version to which their tree should revert, use the commit ID to execute the command. Git revert - undo commit(s) in Git - (code gets reverted on the existing commits) It doesn't revert to the previous state of a project by removing all subsequent commits, it simply undoes a single commit. To view the previous commits, use the git log -oneline command. Let's understand ' git reset -hard' with an example. We need to put the two minuses (-) signs in front of 'hard' as shown in the above syntax.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |