![]() ![]() 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 - undo commit(s) in Git - (code gets reverted on the existing commits) 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. commit-id is the unique id that represents the commit till where we want our changes to be removed.hard represents that we are resetting the commit in a demanding manner, removing the total changes from our current Head position until that particular commit-id.git reset suggests that we are resetting commit(s).So to undo the commit(s) in git using ' git reset -hard', this is the syntax that we need to follow. Git reset hard helps us achieve just that, and using this method, we undo our commit(s), and we also discard the changes to the code or files we had in those deleted commits. Sometimes we may come across a situation where we want to undo unwanted commit(s), make that unwanted commit(s) disappear from the git log, along with undoing the changes made to codes and files at that unwanted commit(s). ![]() Git reset hard - undo commit(s) in Git - (powerful but destructive) ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |