🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 42 (from laksa155)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

ℹ️ Skipped - page is already crawled

đź“„
INDEXABLE
âś…
CRAWLED
15 days ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0.5 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://deadsimplechat.com/blog/git-revert-how-to-the-complete-guide/
Last Crawled2026-03-28 22:24:16 (15 days ago)
First Indexed2023-11-15 02:38:47 (2 years ago)
HTTP Status Code200
Meta TitleGit Revert: How to the complete guide
Meta DescriptionIn this article we are going to learn how to revert a single file in the Git file system. The concept of revert in Git refers to undoing the changes that are made to a Git repository commit history
Meta Canonicalnull
Boilerpipe Text
Editor’s note: This article was last updated on 3 J an 202 5 In this article we are going to learn how to revert a single file in the Git file system Here is what we are going to learn reverting a commit: Step-by-step guide (with real code examples). Handling conflicts that arise during a revert. Reverting a revert. how to revert a single file: Step-by-step guide Reverting multiple commits. Reverting commits that are not the latest in the history. (Plus Git Cherry-pick) Using git log to find the commit to revert to. Troubleshooting common issues that may arise during the process. Contrast between git revert and git reset , and the implications of each. The concept of revert in Git refers to undoing the changes that are made to a Git repository commit history In simple terms it means undoing the commit made to a git repo. The Git revert provides a safe method to undo the code changes in a git repo The git revert command unique feature is that it does not alter the project's commit history which means that the commit record of what changes have been made and by whom remains This is useful when many developers are working on a project When to use git revert When you need to correct a mistake Maintaining Linear progression of commits Selectively reverse some files Avoiding History rewrite How to use here is the basic way to git revert git revert [commit_hash] where the commit_hash is the SHA1 hash of the commit that you want to revert. Running this command will undo the changes introduced by the above commit. Step By Step Guide on how to revert a commit In this section we are going to learn how to revert a commit. Let us learn how to revert a commit step by step Step 1: Identify the commit to revert First we need to decide which commit we want to revert. We can do this by running the git log command which will show a list of commits git log --online this will give you a list of recent commits that are in the git, from here you can choose which one you want to revert a1bas6f (HEAD -> master) Add some feature BOOM e4fd36h Update documentation ZOOM h7i8f9k Fix SOME bug in the code each commit will have a unique hash code that looks something like a98bh74 . Copy the hash code of the commit that you wish to revert If you are looking for a JavaScript Chat SDK , you can consider DeadSimpleChat javascript chat sdk Step 2 Reverting the commit Once we have selected the hash of the commit that we want to revert. Type the below command in your terminal to revert the commit git revert e4fd36h This command will create a new commit that will undo the commit with the hash e4fd36h and thus you would have reverted the commit Step 3: Resolving conflicts, if any sometimes what happens is that there is a conflict. This happens when the changes that we are reverting overlap with the changes that were done after the commit that we are going to revert. If this happens Git stops the process of reverting and notifies you of the conflicting changes and then you can open the files and decide which changes you want to keep and which changes you want to discard When you have resolved all the files you can add the files git add [name of the file] // add all the files using git add . Step 4: Complete the Revert commit Now that we have resolved any conflicts, it is time to commit the revert in the git. Type the below command to commit git commit -m "description for why you are making the commit" Step 5: Push the changes finally push the changes to the git repo. Type the below command git push origin master The complete process # Step 1: first check the commit history git log --oneline # Step 2: select the commit you want to revert git revert nd7hjd9 # Step 3: Resolve any conflicts that might arive # Edit the file(s) in your preferred editor to resolve conflicts # Then mark the resolved files git add [file] # Step 4: Complete the revert commit git commit -m "Revert commit h7i8j9k to fix bug in feature Y" # Step 5: Push the revert commit to the remote repository git push origin master Handling conflicts that arise during a revert Often conflicts arise when doing a revert, this is especially true when you are a part of a team working on a project So, handling conflicts when doing a git revert is important. Let us look at how to do this A conflict when doing a git revert arises when changes in the commit that is being reverted is in conflict with the changes that are made later in the development process and in later commits. The Git cannot automatically resolve this issue because there are overlapping changes in the codebase Steps to handle the conflicts Identify if there are any conflicts Resolve the conflicts using a Diff tool Mark the conflicts as resolved completing the revert verify and push changes Useful tips for handling conflicts Understand the implications: always understand the consequences of reverting  a file Always use a Diff Tool: always use a diff  tool during a conflicts to identify which is the code you want to keep. Keep the commits small: remember to keeps the commits small otherwise large commits are difficult to resolver and creates conflicts if you want to revert some code down the line Reverting a Revert When you revert a commit, Git creates a new commit that undo's the changes of the specific commit. Then when you need the changes, you can revert the revert commit that was created in the first instance Step by step how to revert a revert Identifying the revert commit that you wish to revert You can identify the commit that you wish to revert using the git log --oneline command as done above 2. Reverting the revert commit Similarly, you can revert the revert commit as you normally would revert any commit ( In git revert commit is a commit, just like any other commit) 3. Resolving any conflicts Resolve any conflicts that might arise, use a diff tool for this 4. Completing the process Complete the process by commit the changes after you have reverted the revert commit 5. Push the changes Then push the changes to the remote repository using the git push origin [branch_name] command Tips to consider Understand the implications Commit messages How to revert a Single file Reverting a single file in git means reverting the changes made to a single file in Git without making changes to other files in the comit. This can be useful when you want to undo the changes in one file but leave the rest of the project the same Here is a step by step guide on how to do Step 1 Identify the commit We need to identify the commit that we need to revert. We can use the git log method along with the file name to list the commits related to that specific file git log --[file_path] Step 2 Reverting the changes in the file In this step we are going to revert the changes to a single file. To revert a file before the specified commit. Type the below command git restore [commit_hash]^ -- [file_path] you can also use checkout instead of git restore like so git checkout [commit_hash]^ --[file_path] Here the [commit_hash] is the hash of the commit that we identified in the step one which contains the file that we want to revert to its previous state the ^ symbol signifies a commit just before this one that is the specified commit for example git checkout a23nbe^ -- ./app.js You can also do this using the git restore command git restore --source bfnd235^ -- ./app.js This reverts the changes to a specific file in Git Step 3: Stage and commit the changes After reverting the file to its previous state, you can stage these changes for commit like so git add [file_path] or git add ./app,js after this commit the changes like git commit -m "reverting changes in app.js" step 4: Push the changes lastly push the changes to the remote repo like so git push origin [branch_name] //if it is master then git push origin master Some tips Checking your work Commit History Understanding the Syntax Reverting multiple commits. In this section we are going to learn about reverting mutiples commits in git. A git commit represents the snapshot of your code at a perticular point in time, reverting multiple commits means you are creating a new commit that undo the effects of each specific commit. Steps to revert multiple commits Identify the commits : You can easily identify the commits that you need to revert by using the git log command like so git log --oneline The command provides a list of commits from which you can choose which one you want to revert Revert the commits individually You can revert the commit one by one. this can be done, start from the most recent one and move backwards lke git revert [most-recent-commit-hash] git revert [next-most-recent-commit-hash] With each revert command the git creates a new commit and if there are any conflicts the git would stop the process and let you know and then you can resolve the conflicts and start the process again Reverting a series of commits you can also revert a series on commit and additionally with the --no-commit option you can tell the git not to commit after each revert and when all the reverts are done you can create a commit git revert --no-commit [most-recent-commit-hash]^..[oldest-commit-hash] git commit -m "Revert commits related to a specific feature" This creates a single commit for all the reverts that you have done. Resolving commits: If there are any conflicts the git would stop the process of reverting and you will have to manually resolve the conflicts. you can resolve the conflicts manually in the specific files and then commit them git add [file] Push the changes When all the changes have been done you can push your changes to the remote repository with git push origin master Reverting commits that are not in the latest history When you want to revert hte commit that is not in the latest commit, the process can get more complicated. Understanding the process In Git, the commits are in a chronological chain. When you revert a commit that is far back in the commit chain, you are effectively undoing changes that might have built upon by multiple subsequent commits. The later commits in the chain might have introduced additional changes that could cause overlap with the earlier commit This could lead to merge conflicts and other such complexities. Let us understand this with an example (A)---(B)---(C)---(D)---(E)---(F) Here (F) is the latest commit or master. If you want to revert to (B) , you have to remember what changes are there in c,d,e and f and these might rely on the code in B which will cause conflicts if you revert the B Step By Step process to reverting the non latest commit 1 Identify the commit to revert a. Run git log --online This will show a small list of commits with their short SHA1 hashes and commit messages, like this git log --online b. Copy the hash Find the commit that you wish to revert and copy its hash like so B with hash hfjdk758394 2 Run the git revert Command a. Check the Branch Make sure that you are on the branch where the commit that is to be reverted exists git checkout master b. Revert the commit git revert hfjdk758394 This creates a new commit on top of the current branch Git attempts to apply the inverse patch of commit hfjdk758394 to your working tree 3. Resolve Conflicts The commit that we reverted hfjdk758394 is not the latest commit there is a good chance that code base might have diverged significantly since that commit Git might detect the overlapping changes between the commit that we reverted that is hfjdk758394 and the subsequent commits. You can see the conflict markers in the files like so <<<<<<< HEAD // code from the latest commit ======= // code from the commit being reverted >>>>>>> hfjdk758394 In order to resolve the conflicts Open the affected files: Look for lines with <<<<<<< HEAD , ======= and >>>>> <commit_hash> 2. Decide which changes you want to keep Manually edit the conflicting sections to keep the changes that you want and remove the conflict markers 3. Mark as resolved Once you have resolve the conflicts then you can stage the changes to be commited like so git add <file1> <file2> ... 4. Complete the rever commit Finish by committing the changes git commit -m "Revert the commit hfjdk758394 while preserving subsequent code" 5. Push the changes lastly push the changes like git push origin master Revert VS Cherry Pick Alternative many times you are looking to remove something or fix something from an older commit but still want to keep some changes from that commit In this situation you can consider a partial revert or a combination of revert and cherry-pick for instance you can Cherry-pick specific changes that you want to keep , on to a new branch Revert the entire commit on the master branch Merge the new branch that cherry-picked the good changes back into master This approach allows you to selectively remove only the undiseired changes that were there in the older commit, leaving the good parts of that commit intact. What is git cherry pick the git cherry-pick <commit_hash> takes changes from one commit, this could be from anywhere in the history and applies them as a commit on top of your current branch This is used to bring specific features or bug fix from one branch to another without merging the branch How it works Identify the Commit to copy You can do this using git log command 2. Cherry pick the commit git cherry-pick <commit_hash> This will put the changes on top of your current branch 3. Commit After this resolve any merge conflicts and the new cerry-picked commit is the new commit on your branch Troubleshooting common issues that may arise during the process. issues might arise when you are reverting changes in your git repository. Here is a look at some of the common issues that might arise and how you can troubleshoot them Merge Conflicts : Commit not found : Reverting a Merge Commit File not found Permission denied Incomplete Revert Push rejected Difference between git revert and git reset and what are the consequences of each git revert and git reset are two different types of git commands that allow you to undo changes previously made in the git repository Git revert Git revert creates a new commit that undoes a previous commit. It does not change the commit history git revert [commit_hash] Important points Non-destructive Traceable collaboration-friendly Git reset git reset resets the current HEAD in git to a specified date. Depending on the options that is --soft, --hard or --mixed it can unstage changes, discard them completely or change the commit history git reset --hard [commit_hash] Destructive in nature Rewrites commit history local by default DeadSimpleChat Need Chat API for your website or app DeadSimpleChat is an Chat API provider Add Scalable Chat to your app in minutes 10 Million Online Concurrent users 99.999% Uptime Moderation features 1-1 Chat Group Chat Fully Customizable Chat API and SDK Pre-Built Chat Conclusion In this article we learned about git revert and how to perform git revert and its other intricacies Here is a recap of the key points in this guide Step-by-step how to revert a commit How to resolve conflicts Reverting a revert Multiple and non latest commits Single file revert Git revert and git reset I hope you liked the article. Thank you for reading Ready to Add Chat to Your Website? Get started for free. No credit card required. Start a Free Trial
Markdown
[DeadSimpleChat](https://deadsimplechat.com/) - SDKs [JS **JavaScript SDK** Integrate Chat into any app or website](https://deadsimplechat.com/javascript-chat-api-sdk) [**React Native** React Native Chat SDK for in-app messaging](https://deadsimplechat.com/react-native-chat-sdk) [**Flutter** Flutter Chat SDK for in-app messaging](https://deadsimplechat.com/flutter-chat-sdk) [**Developer Quick Start** Get started with the API & docs](https://deadsimplechat.com/developer/) [Start a Free Trial](https://deadsimplechat.com/getstarted) [Contact Sales](https://calendly.com/deadsimplechat/15min) - [Features](https://deadsimplechat.com/features) - [Pricing](https://deadsimplechat.com/pricing) - Solutions [Live Streaming](https://deadsimplechat.com/live-streaming-chat) [Gaming](https://deadsimplechat.com/solutions/gaming) [Social & Community Chat](https://deadsimplechat.com/solutions/chat-for-online-communities-social) [Marketplace](https://deadsimplechat.com/solutions/marketplace-chat) [Education](https://deadsimplechat.com/solutions/chat-for-education-platform) [Finance](https://deadsimplechat.com/solutions/financial-services) - [Blog](https://deadsimplechat.com/blog) [Log in](https://deadsimplechat.com/login) [Sign Up](https://deadsimplechat.com/getstarted) [JavaScript SDK](https://deadsimplechat.com/javascript-chat-api-sdk) [React Native SDK](https://deadsimplechat.com/react-native-chat-sdk) [Flutter SDK](https://deadsimplechat.com/flutter-chat-sdk) [Features](https://deadsimplechat.com/features) [Pricing](https://deadsimplechat.com/pricing) [Live Streaming](https://deadsimplechat.com/live-streaming-chat) [Gaming](https://deadsimplechat.com/solutions/gaming) [Social & Community](https://deadsimplechat.com/solutions/chat-for-online-communities-social) [Blog](https://deadsimplechat.com/blog) [Log in](https://deadsimplechat.com/login) [Sign Up Free](https://deadsimplechat.com/getstarted) [Home](https://deadsimplechat.com/blog) › Git Revert: How to the complete guide 10 min read # Git Revert: How to the complete guide Dead Simple Chat Team November 14, 2023 ![Git Revert: How to the complete guide](https://deadsimplechat.com/blog/content/images/size/w2000/2023/11/DALL-E-2023-11-14-14.42.44---A-3D-vector-banner-image-for-a-blog-post-titled--Git-Revert_-How-to-the-complete-guide.--The-image-features-a-dynamic-digital-environment-with-bold-li.png) ******Editor’s note:**********This article was last updated** on**3* ***J****an* ***202****5** In this article we are going to learn how to revert a single file in the Git file system Here is what we are going to learn - [reverting a commit: Step-by-step guide (with real code examples).](https://deadsimplechat.com/blog/git-revert-how-to-the-complete-guide/#step-by-step-guide-on-how-to-revert-a-commit) - [Handling conflicts that arise during a revert.](https://deadsimplechat.com/blog/git-revert-how-to-the-complete-guide/#handling-conflicts-that-arise-during-a-revert) - [Reverting a revert.](https://deadsimplechat.com/blog/git-revert-how-to-the-complete-guide/#reverting-a-revert) - [how to revert a single file: Step-by-step guide](https://deadsimplechat.com/blog/git-revert-how-to-the-complete-guide/#how-to-revert-a-single-file) - [Reverting multiple commits.](https://deadsimplechat.com/blog/git-revert-how-to-the-complete-guide/#reverting-multiple-commits) - [Reverting commits that are not the latest in the history.](https://deadsimplechat.com/blog/git-revert-how-to-the-complete-guide/#reverting-commits-that-are-not-in-the-latest-history) (Plus Git Cherry-pick) - Using `git log` to find the commit to revert to. - Troubleshooting common issues that may arise during the process. - Contrast between `git revert` and `git reset`, and the implications of each. The concept of revert in Git refers to undoing the changes that are made to a Git repository commit history In simple terms it means undoing the commit made to a git repo. The Git revert provides a safe method to undo the code changes in a git repo The git revert command unique feature is that it does not alter the project's commit history which means that the commit record of what changes have been made and by whom remains This is useful when many developers are working on a project ## When to use `git revert` 1. When you need to correct a mistake 2. Maintaining Linear progression of commits 3. Selectively reverse some files 4. Avoiding History rewrite ### How to use here is the basic way to git revert ``` git revert [commit_hash] ``` where the commit\_hash is the SHA1 hash of the commit that you want to revert. Running this command will undo the changes introduced by the above commit. ## Step By Step Guide on how to revert a commit In this section we are going to learn how to revert a commit. Let us learn how to revert a commit step by step ## Step 1: Identify the commit to revert First we need to decide which commit we want to revert. We can do this by running the `git log` command which will show a list of commits ``` git log --online ``` this will give you a list of recent commits that are in the git, from here you can choose which one you want to revert ``` a1bas6f (HEAD -> master) Add some feature BOOM e4fd36h Update documentation ZOOM h7i8f9k Fix SOME bug in the code ``` each commit will have a unique hash code that looks something like `a98bh74` . Copy the hash code of the commit that you wish to revert If you are looking for a [JavaScript Chat SDK](https://deadsimplechat.com/javascript-chat-api-sdk?ref=deadsimplechat.com), you can consider [DeadSimpleChat javascript chat sdk](https://deadsimplechat.com/developer/sdk/quick-start?ref=deadsimplechat.com) ## Step 2 Reverting the commit Once we have selected the hash of the commit that we want to revert. Type the below command in your terminal to revert the commit ``` git revert e4fd36h ``` This command will create a new commit that will undo the commit with the hash `e4fd36h` and thus you would have reverted the commit ## Step 3: Resolving conflicts, if any sometimes what happens is that there is a conflict. This happens when the changes that we are reverting overlap with the changes that were done after the commit that we are going to revert. If this happens Git stops the process of reverting and notifies you of the conflicting changes and then you can open the files and decide which changes you want to keep and which changes you want to discard When you have resolved all the files you can add the files ``` git add [name of the file] // add all the files using git add . ``` ## Step 4: Complete the Revert commit Now that we have resolved any conflicts, it is time to commit the revert in the git. Type the below command to commit ``` git commit -m "description for why you are making the commit" ``` ## Step 5: Push the changes finally push the changes to the git repo. Type the below command ``` git push origin master ``` ## The complete process ``` # Step 1: first check the commit history git log --oneline # Step 2: select the commit you want to revert git revert nd7hjd9 # Step 3: Resolve any conflicts that might arive # Edit the file(s) in your preferred editor to resolve conflicts # Then mark the resolved files git add [file] # Step 4: Complete the revert commit git commit -m "Revert commit h7i8j9k to fix bug in feature Y" # Step 5: Push the revert commit to the remote repository git push origin master ``` ## Handling conflicts that arise during a revert Often conflicts arise when doing a revert, this is especially true when you are a part of a team working on a project So, handling conflicts when doing a git revert is important. Let us look at how to do this A conflict when doing a `git revert` arises when changes in the commit that is being reverted is in conflict with the changes that are made later in the development process and in later commits. The Git cannot automatically resolve this issue because there are overlapping changes in the codebase ## Steps to handle the conflicts 1. Identify if there are any conflicts 2. Resolve the conflicts using a Diff tool 3. Mark the conflicts as resolved 4. completing the revert 5. verify and push changes ### Useful tips for handling conflicts - Understand the implications: always understand the consequences of reverting a file - Always use a Diff Tool: always use a diff tool during a conflicts to identify which is the code you want to keep. - Keep the commits small: remember to keeps the commits small otherwise large commits are difficult to resolver and creates conflicts if you want to revert some code down the line ## Reverting a Revert When you revert a commit, Git creates a new commit that undo's the changes of the specific commit. Then when you need the changes, you can revert the revert commit that was created in the first instance ### Step by step how to revert a revert 1. **Identifying the revert commit that you wish to revert** You can identify the commit that you wish to revert using the `git log --oneline` command as done above **2\. Reverting the revert commit** Similarly, you can revert the revert commit as you normally would revert any commit ( In git revert commit is a commit, just like any other commit) **3\. Resolving any conflicts** Resolve any conflicts that might arise, use a diff tool for this **4\. Completing the process** Complete the process by commit the changes after you have reverted the revert commit **5\. Push the changes** Then push the changes to the remote repository using the `git push origin [branch_name]` command ### Tips to consider 1. Understand the implications 2. Commit messages ## How to revert a Single file Reverting a single file in git means reverting the changes made to a single file in Git without making changes to other files in the comit. This can be useful when you want to undo the changes in one file but leave the rest of the project the same Here is a step by step guide on how to do ### Step 1 Identify the commit We need to identify the commit that we need to revert. We can use the `git log` method along with the file name to list the commits related to that specific file ``` git log --[file_path] ``` ## Step 2 Reverting the changes in the file In this step we are going to revert the changes to a single file. To revert a file before the specified commit. Type the below command ``` git restore [commit_hash]^ -- [file_path] ``` you can also use checkout instead of `git restore` like so ``` git checkout [commit_hash]^ --[file_path] ``` Here the \[commit\_hash\] is the hash of the commit that we identified in the step one which contains the file that we want to revert to its previous state the `^` symbol signifies a commit just before this one that is the specified commit for example ``` git checkout a23nbe^ -- ./app.js ``` You can also do this using the git restore command ``` git restore --source bfnd235^ -- ./app.js ``` This reverts the changes to a specific file in Git ### Step 3: Stage and commit the changes After reverting the file to its previous state, you can stage these changes for commit like so ``` git add [file_path] ``` or ``` git add ./app,js ``` after this commit the changes like ``` git commit -m "reverting changes in app.js" ``` ## step 4: Push the changes lastly push the changes to the remote repo like so ``` git push origin [branch_name] //if it is master then git push origin master ``` ### Some tips - Checking your work - Commit History - Understanding the Syntax ## Reverting multiple commits. In this section we are going to learn about reverting mutiples commits in git. A git commit represents the snapshot of your code at a perticular point in time, reverting multiple commits means you are creating a new commit that undo the effects of each specific commit. ### Steps to revert multiple commits - **Identify the commits**: You can easily identify the commits that you need to revert by using the git log command like so ``` git log --oneline ``` The command provides a list of commits from which you can choose which one you want to revert - **Revert the commits individually** You can revert the commit one by one. this can be done, start from the most recent one and move backwards lke ``` git revert [most-recent-commit-hash] git revert [next-most-recent-commit-hash] ``` With each revert command the git creates a new commit and if there are any conflicts the git would stop the process and let you know and then you can resolve the conflicts and start the process again - **Reverting a series of commits** you can also revert a series on commit and additionally with the `--no-commit` option you can tell the git not to commit after each revert and when all the reverts are done you can create a commit ``` git revert --no-commit [most-recent-commit-hash]^..[oldest-commit-hash] git commit -m "Revert commits related to a specific feature" ``` This creates a single commit for all the reverts that you have done. - **Resolving commits:** If there are any conflicts the git would stop the process of reverting and you will have to manually resolve the conflicts. you can resolve the conflicts manually in the specific files and then commit them ``` git add [file] ``` - **Push the changes** When all the changes have been done you can push your changes to the remote repository with ``` git push origin master ``` *** ## Reverting commits that are not in the latest history When you want to revert hte commit that is ***not*** in the latest commit, the process can get more complicated. ### Understanding the process In Git, the commits are in a chronological chain. When you revert a commit that is far back in the commit chain, you are effectively undoing changes that might have built upon by multiple subsequent commits. The later commits in the chain might have introduced additional changes that could cause overlap with the earlier commit This could lead to merge conflicts and other such complexities. Let us understand this with an example ``` (A)---(B)---(C)---(D)---(E)---(F) ``` Here `(F)` is the latest commit or master. If you want to revert to `(B)` , you have to remember what changes are there in c,d,e and f and these might rely on the code in B which will cause conflicts if you revert the B ### Step By Step process to reverting the non latest commit ### 1 Identify the commit to revert a. Run `git log --online` This will show a small list of commits with their short SHA1 hashes and commit messages, like this ``` git log --online ``` b. Copy the hash Find the commit that you wish to revert and copy its hash like so `B` with hash `hfjdk758394` ### 2 Run the `git revert` Command a. Check the Branch Make sure that you are on the branch where the commit that is to be reverted exists ``` git checkout master ``` b. Revert the commit ``` git revert hfjdk758394 ``` - This creates a new commit on top of the current branch - Git attempts to apply the inverse patch of commit `hfjdk758394` to your working tree ## 3\. Resolve Conflicts The commit that we reverted `hfjdk758394` is not the latest commit there is a good chance that code base might have diverged significantly since that commit Git might detect the overlapping changes between the commit that we reverted that is `hfjdk758394` and the subsequent commits. You can see the conflict markers in the files like so ``` <<<<<<< HEAD // code from the latest commit ======= // code from the commit being reverted >>>>>>> hfjdk758394 ``` In order to resolve the conflicts 1. Open the affected files: Look for lines with `<<<<<<< HEAD` , `=======` and `>>>>> <commit_hash>` 2\. Decide which changes you want to keep Manually edit the conflicting sections to keep the changes that you want and remove the conflict markers 3\. Mark as resolved Once you have resolve the conflicts then you can stage the changes to be commited like so ``` git add <file1> <file2> ... ``` 4\. Complete the rever commit Finish by committing the changes ``` git commit -m "Revert the commit hfjdk758394 while preserving subsequent code" ``` 5\. Push the changes lastly push the changes like ``` git push origin master ``` ## Revert VS Cherry Pick Alternative many times you are looking to remove something or fix something from an older commit but still want to keep some changes from that commit In this situation you can consider a partial revert or a combination of revert and cherry-pick for instance you can 1. Cherry-pick specific changes that you want to keep , on to a new branch 2. Revert the entire commit on the `master` branch 3. Merge the new branch that cherry-picked the good changes back into master This approach allows you to selectively remove only the undiseired changes that were there in the older commit, leaving the good parts of that commit intact. ### What is git cherry pick the `git cherry-pick <commit_hash>` takes changes from one commit, this could be from anywhere in the history and applies them as a commit on top of your current branch This is used to bring specific features or bug fix from one branch to another without merging the branch ### How it works 1. Identify the Commit to copy You can do this using `git log` command 2\. Cherry pick the commit `git cherry-pick <commit_hash>` This will put the changes on top of your current branch 3\. Commit After this resolve any merge conflicts and the new cerry-picked commit is the new commit on your branch *** ## Troubleshooting common issues that may arise during the process. issues might arise when you are reverting changes in your git repository. Here is a look at some of the common issues that might arise and how you can troubleshoot them - **Merge Conflicts**: - **Commit not found**: - **Reverting a Merge Commit** - **File not found** - **Permission denied** - **Incomplete Revert** - **Push rejected** ## Difference between `git revert` and `git reset` and what are the consequences of each `git revert` and `git reset` are two different types of git commands that allow you to undo changes previously made in the git repository ### Git revert Git revert creates a new commit that undoes a previous commit. It does not change the commit history ``` git revert [commit_hash] ``` Important points - Non-destructive - Traceable - collaboration-friendly ### Git reset `git reset` resets the current HEAD in git to a specified date. Depending on the options that is --soft, --hard or --mixed it can unstage changes, discard them completely or change the commit history ``` git reset --hard [commit_hash] ``` - Destructive in nature - Rewrites commit history - local by default ![](https://deadsimplechat.com/blog/content/images/2023/10/Screenshot_2-2-4.png) DeadSimpleChat ## Need [Chat API](https://deadsimplechat.com/?ref=deadsimplechat.com) for your website or app [DeadSimpleChat](https://deadsimplechat.com/?ref=deadsimplechat.com) is an Chat API provider - Add Scalable Chat to your app in minutes - 10 Million Online Concurrent users - 99\.999% Uptime - Moderation features - 1-1 Chat - Group Chat - Fully Customizable - Chat API and SDK - Pre-Built Chat ## Conclusion In this article we learned about git revert and how to perform git revert and its other intricacies Here is a recap of the key points in this guide 1. Step-by-step how to revert a commit 2. How to resolve conflicts 3. Reverting a revert 4. Multiple and non latest commits 5. Single file revert 6. Git revert and git reset I hope you liked the article. Thank you for reading ### Ready to Add Chat to Your Website? Get started for free. No credit card required. [Start a Free Trial](https://deadsimplechat.com/getstarted) *** #### Dead Simple Chat Team Author at Dead Simple Chat Blog Share this article On this page ## Related Articles [![Virtual Town Hall: The Complete Guide for 2026](https://deadsimplechat.com/blog/content/images/size/w600/2026/02/townhall-image.png) Virtual Town Hall: The Complete Guide for 2026 You've seen it happen. Your virtual town hall starts with the CEO talking, slides appear, and within ten minutes half Dead Simple Chat Team · 17 min read](https://deadsimplechat.com/blog/virtual-town-hall-the-complete-guide-for-2026/) [![Webinar Chat: The Complete Guide to Engaging Your Audience \[2026\]](https://deadsimplechat.com/blog/content/images/size/w600/2026/02/article-hero-webinar-chat.svg) Webinar Chat: The Complete Guide to Engaging Your Audience \[2026\] Your webinar just hit 500 attendees. The presenter is delivering valuable content. But the audience? Silent. Passive. Already checking email in another Dead Simple Chat Team · 13 min read](https://deadsimplechat.com/blog/webinar-chat-the-complete-guide-to-engaging-your-audience/) [![11 DigitalOcean Alternatives for 2026](https://deadsimplechat.com/blog/content/images/size/w600/2025/09/digitalocean-alternatives.png) 11 DigitalOcean Alternatives for 2026 In this article we are going to look at some of the DigitalOcean Alternatives TL;DR Quick Picks Drop in DigitalOcean alternatives: Dead Simple Chat Team · 12 min read](https://deadsimplechat.com/blog/digital-ocean-alternatives/) #### Solutions - [Blog](https://deadsimplechat.com/blog) - [Features](https://deadsimplechat.com/features) - [Live Streaming Chat](https://deadsimplechat.com/live-streaming-chat) - [JavaScript Chat API and SDK](https://deadsimplechat.com/javascript-chat-api-sdk) #### Resources - [Embed Group Chat on Website](https://deadsimplechat.com/chat) - [Chat for Live Events](https://deadsimplechat.com/chatforliveevents) - [Virtual Event Chat](https://deadsimplechat.com/virtual-event-chat) - [Group Chat Platform](https://deadsimplechat.com/group-chat-platform) - [Chat API for Website](https://deadsimplechat.com/chat-api-for-website) #### Support - [Pricing](https://deadsimplechat.com/pricing) - [Documentation](https://support.deadsimplechat.com/) - [Support](https://support.deadsimplechat.com/) - [FAQ](https://deadsimplechat.com/faq) #### Developer - [Developer Documentation](https://developer.deadsimplechat.com/) - [Single Sign On (SSO)](https://deadsimplechat.com/developer/single-sign-on/basic-sso) - [Chat SDK Documentation](https://deadsimplechat.com/developer/sdk/quick-start) - [Chat API Documentation](https://deadsimplechat.com/developer/rest-api/get-all-chatrooms) #### Legal - [GDPR](https://deadsimplechat.com/gdpr) - [Security](https://deadsimplechat.com/security) - [Privacy](https://deadsimplechat.com/privacy) - [Terms](https://deadsimplechat.com/terms) © 2026 Next Path Software Consulting Inc. All rights reserved. [DeadSimpleChat.com](https://deadsimplechat.com/)
Readable Markdown
******Editor’s note:**********This article was last updated** on**3* ***J****an* ***202****5** In this article we are going to learn how to revert a single file in the Git file system Here is what we are going to learn - [reverting a commit: Step-by-step guide (with real code examples).](https://deadsimplechat.com/blog/git-revert-how-to-the-complete-guide/#step-by-step-guide-on-how-to-revert-a-commit) - [Handling conflicts that arise during a revert.](https://deadsimplechat.com/blog/git-revert-how-to-the-complete-guide/#handling-conflicts-that-arise-during-a-revert) - [Reverting a revert.](https://deadsimplechat.com/blog/git-revert-how-to-the-complete-guide/#reverting-a-revert) - [how to revert a single file: Step-by-step guide](https://deadsimplechat.com/blog/git-revert-how-to-the-complete-guide/#how-to-revert-a-single-file) - [Reverting multiple commits.](https://deadsimplechat.com/blog/git-revert-how-to-the-complete-guide/#reverting-multiple-commits) - [Reverting commits that are not the latest in the history.](https://deadsimplechat.com/blog/git-revert-how-to-the-complete-guide/#reverting-commits-that-are-not-in-the-latest-history) (Plus Git Cherry-pick) - Using `git log` to find the commit to revert to. - Troubleshooting common issues that may arise during the process. - Contrast between `git revert` and `git reset`, and the implications of each. The concept of revert in Git refers to undoing the changes that are made to a Git repository commit history In simple terms it means undoing the commit made to a git repo. The Git revert provides a safe method to undo the code changes in a git repo The git revert command unique feature is that it does not alter the project's commit history which means that the commit record of what changes have been made and by whom remains This is useful when many developers are working on a project ## When to use `git revert` 1. When you need to correct a mistake 2. Maintaining Linear progression of commits 3. Selectively reverse some files 4. Avoiding History rewrite ### How to use here is the basic way to git revert ``` git revert [commit_hash] ``` where the commit\_hash is the SHA1 hash of the commit that you want to revert. Running this command will undo the changes introduced by the above commit. ## Step By Step Guide on how to revert a commit In this section we are going to learn how to revert a commit. Let us learn how to revert a commit step by step ## Step 1: Identify the commit to revert First we need to decide which commit we want to revert. We can do this by running the `git log` command which will show a list of commits ``` git log --online ``` this will give you a list of recent commits that are in the git, from here you can choose which one you want to revert ``` a1bas6f (HEAD -> master) Add some feature BOOM e4fd36h Update documentation ZOOM h7i8f9k Fix SOME bug in the code ``` each commit will have a unique hash code that looks something like `a98bh74` . Copy the hash code of the commit that you wish to revert If you are looking for a [JavaScript Chat SDK](https://deadsimplechat.com/javascript-chat-api-sdk?ref=deadsimplechat.com), you can consider [DeadSimpleChat javascript chat sdk](https://deadsimplechat.com/developer/sdk/quick-start?ref=deadsimplechat.com) ## Step 2 Reverting the commit Once we have selected the hash of the commit that we want to revert. Type the below command in your terminal to revert the commit ``` git revert e4fd36h ``` This command will create a new commit that will undo the commit with the hash `e4fd36h` and thus you would have reverted the commit ## Step 3: Resolving conflicts, if any sometimes what happens is that there is a conflict. This happens when the changes that we are reverting overlap with the changes that were done after the commit that we are going to revert. If this happens Git stops the process of reverting and notifies you of the conflicting changes and then you can open the files and decide which changes you want to keep and which changes you want to discard When you have resolved all the files you can add the files ``` git add [name of the file] // add all the files using git add . ``` ## Step 4: Complete the Revert commit Now that we have resolved any conflicts, it is time to commit the revert in the git. Type the below command to commit ``` git commit -m "description for why you are making the commit" ``` ## Step 5: Push the changes finally push the changes to the git repo. Type the below command ``` git push origin master ``` ## The complete process ``` # Step 1: first check the commit history git log --oneline # Step 2: select the commit you want to revert git revert nd7hjd9 # Step 3: Resolve any conflicts that might arive # Edit the file(s) in your preferred editor to resolve conflicts # Then mark the resolved files git add [file] # Step 4: Complete the revert commit git commit -m "Revert commit h7i8j9k to fix bug in feature Y" # Step 5: Push the revert commit to the remote repository git push origin master ``` ## Handling conflicts that arise during a revert Often conflicts arise when doing a revert, this is especially true when you are a part of a team working on a project So, handling conflicts when doing a git revert is important. Let us look at how to do this A conflict when doing a `git revert` arises when changes in the commit that is being reverted is in conflict with the changes that are made later in the development process and in later commits. The Git cannot automatically resolve this issue because there are overlapping changes in the codebase ## Steps to handle the conflicts 1. Identify if there are any conflicts 2. Resolve the conflicts using a Diff tool 3. Mark the conflicts as resolved 4. completing the revert 5. verify and push changes ### Useful tips for handling conflicts - Understand the implications: always understand the consequences of reverting a file - Always use a Diff Tool: always use a diff tool during a conflicts to identify which is the code you want to keep. - Keep the commits small: remember to keeps the commits small otherwise large commits are difficult to resolver and creates conflicts if you want to revert some code down the line ## Reverting a Revert When you revert a commit, Git creates a new commit that undo's the changes of the specific commit. Then when you need the changes, you can revert the revert commit that was created in the first instance ### Step by step how to revert a revert 1. **Identifying the revert commit that you wish to revert** You can identify the commit that you wish to revert using the `git log --oneline` command as done above **2\. Reverting the revert commit** Similarly, you can revert the revert commit as you normally would revert any commit ( In git revert commit is a commit, just like any other commit) **3\. Resolving any conflicts** Resolve any conflicts that might arise, use a diff tool for this **4\. Completing the process** Complete the process by commit the changes after you have reverted the revert commit **5\. Push the changes** Then push the changes to the remote repository using the `git push origin [branch_name]` command ### Tips to consider 1. Understand the implications 2. Commit messages ## How to revert a Single file Reverting a single file in git means reverting the changes made to a single file in Git without making changes to other files in the comit. This can be useful when you want to undo the changes in one file but leave the rest of the project the same Here is a step by step guide on how to do ### Step 1 Identify the commit We need to identify the commit that we need to revert. We can use the `git log` method along with the file name to list the commits related to that specific file ``` git log --[file_path] ``` ## Step 2 Reverting the changes in the file In this step we are going to revert the changes to a single file. To revert a file before the specified commit. Type the below command ``` git restore [commit_hash]^ -- [file_path] ``` you can also use checkout instead of `git restore` like so ``` git checkout [commit_hash]^ --[file_path] ``` Here the \[commit\_hash\] is the hash of the commit that we identified in the step one which contains the file that we want to revert to its previous state the `^` symbol signifies a commit just before this one that is the specified commit for example ``` git checkout a23nbe^ -- ./app.js ``` You can also do this using the git restore command ``` git restore --source bfnd235^ -- ./app.js ``` This reverts the changes to a specific file in Git ### Step 3: Stage and commit the changes After reverting the file to its previous state, you can stage these changes for commit like so ``` git add [file_path] ``` or ``` git add ./app,js ``` after this commit the changes like ``` git commit -m "reverting changes in app.js" ``` ## step 4: Push the changes lastly push the changes to the remote repo like so ``` git push origin [branch_name] //if it is master then git push origin master ``` ### Some tips - Checking your work - Commit History - Understanding the Syntax ## Reverting multiple commits. In this section we are going to learn about reverting mutiples commits in git. A git commit represents the snapshot of your code at a perticular point in time, reverting multiple commits means you are creating a new commit that undo the effects of each specific commit. ### Steps to revert multiple commits - **Identify the commits**: You can easily identify the commits that you need to revert by using the git log command like so ``` git log --oneline ``` The command provides a list of commits from which you can choose which one you want to revert - **Revert the commits individually** You can revert the commit one by one. this can be done, start from the most recent one and move backwards lke ``` git revert [most-recent-commit-hash] git revert [next-most-recent-commit-hash] ``` With each revert command the git creates a new commit and if there are any conflicts the git would stop the process and let you know and then you can resolve the conflicts and start the process again - **Reverting a series of commits** you can also revert a series on commit and additionally with the `--no-commit` option you can tell the git not to commit after each revert and when all the reverts are done you can create a commit ``` git revert --no-commit [most-recent-commit-hash]^..[oldest-commit-hash] git commit -m "Revert commits related to a specific feature" ``` This creates a single commit for all the reverts that you have done. - **Resolving commits:** If there are any conflicts the git would stop the process of reverting and you will have to manually resolve the conflicts. you can resolve the conflicts manually in the specific files and then commit them ``` git add [file] ``` - **Push the changes** When all the changes have been done you can push your changes to the remote repository with ``` git push origin master ``` *** ## Reverting commits that are not in the latest history When you want to revert hte commit that is ***not*** in the latest commit, the process can get more complicated. ### Understanding the process In Git, the commits are in a chronological chain. When you revert a commit that is far back in the commit chain, you are effectively undoing changes that might have built upon by multiple subsequent commits. The later commits in the chain might have introduced additional changes that could cause overlap with the earlier commit This could lead to merge conflicts and other such complexities. Let us understand this with an example ``` (A)---(B)---(C)---(D)---(E)---(F) ``` Here `(F)` is the latest commit or master. If you want to revert to `(B)` , you have to remember what changes are there in c,d,e and f and these might rely on the code in B which will cause conflicts if you revert the B ### Step By Step process to reverting the non latest commit ### 1 Identify the commit to revert a. Run `git log --online` This will show a small list of commits with their short SHA1 hashes and commit messages, like this ``` git log --online ``` b. Copy the hash Find the commit that you wish to revert and copy its hash like so `B` with hash `hfjdk758394` ### 2 Run the `git revert` Command a. Check the Branch Make sure that you are on the branch where the commit that is to be reverted exists ``` git checkout master ``` b. Revert the commit ``` git revert hfjdk758394 ``` - This creates a new commit on top of the current branch - Git attempts to apply the inverse patch of commit `hfjdk758394` to your working tree ## 3\. Resolve Conflicts The commit that we reverted `hfjdk758394` is not the latest commit there is a good chance that code base might have diverged significantly since that commit Git might detect the overlapping changes between the commit that we reverted that is `hfjdk758394` and the subsequent commits. You can see the conflict markers in the files like so ``` <<<<<<< HEAD // code from the latest commit ======= // code from the commit being reverted >>>>>>> hfjdk758394 ``` In order to resolve the conflicts 1. Open the affected files: Look for lines with `<<<<<<< HEAD` , `=======` and `>>>>> <commit_hash>` 2\. Decide which changes you want to keep Manually edit the conflicting sections to keep the changes that you want and remove the conflict markers 3\. Mark as resolved Once you have resolve the conflicts then you can stage the changes to be commited like so ``` git add <file1> <file2> ... ``` 4\. Complete the rever commit Finish by committing the changes ``` git commit -m "Revert the commit hfjdk758394 while preserving subsequent code" ``` 5\. Push the changes lastly push the changes like ``` git push origin master ``` ## Revert VS Cherry Pick Alternative many times you are looking to remove something or fix something from an older commit but still want to keep some changes from that commit In this situation you can consider a partial revert or a combination of revert and cherry-pick for instance you can 1. Cherry-pick specific changes that you want to keep , on to a new branch 2. Revert the entire commit on the `master` branch 3. Merge the new branch that cherry-picked the good changes back into master This approach allows you to selectively remove only the undiseired changes that were there in the older commit, leaving the good parts of that commit intact. ### What is git cherry pick the `git cherry-pick <commit_hash>` takes changes from one commit, this could be from anywhere in the history and applies them as a commit on top of your current branch This is used to bring specific features or bug fix from one branch to another without merging the branch ### How it works 1. Identify the Commit to copy You can do this using `git log` command 2\. Cherry pick the commit `git cherry-pick <commit_hash>` This will put the changes on top of your current branch 3\. Commit After this resolve any merge conflicts and the new cerry-picked commit is the new commit on your branch *** ## Troubleshooting common issues that may arise during the process. issues might arise when you are reverting changes in your git repository. Here is a look at some of the common issues that might arise and how you can troubleshoot them - **Merge Conflicts**: - **Commit not found**: - **Reverting a Merge Commit** - **File not found** - **Permission denied** - **Incomplete Revert** - **Push rejected** ## Difference between `git revert` and `git reset` and what are the consequences of each `git revert` and `git reset` are two different types of git commands that allow you to undo changes previously made in the git repository ### Git revert Git revert creates a new commit that undoes a previous commit. It does not change the commit history ``` git revert [commit_hash] ``` Important points - Non-destructive - Traceable - collaboration-friendly ### Git reset `git reset` resets the current HEAD in git to a specified date. Depending on the options that is --soft, --hard or --mixed it can unstage changes, discard them completely or change the commit history ``` git reset --hard [commit_hash] ``` - Destructive in nature - Rewrites commit history - local by default ![](https://deadsimplechat.com/blog/content/images/2023/10/Screenshot_2-2-4.png) DeadSimpleChat ## Need [Chat API](https://deadsimplechat.com/?ref=deadsimplechat.com) for your website or app [DeadSimpleChat](https://deadsimplechat.com/?ref=deadsimplechat.com) is an Chat API provider - Add Scalable Chat to your app in minutes - 10 Million Online Concurrent users - 99\.999% Uptime - Moderation features - 1-1 Chat - Group Chat - Fully Customizable - Chat API and SDK - Pre-Built Chat ## Conclusion In this article we learned about git revert and how to perform git revert and its other intricacies Here is a recap of the key points in this guide 1. Step-by-step how to revert a commit 2. How to resolve conflicts 3. Reverting a revert 4. Multiple and non latest commits 5. Single file revert 6. Git revert and git reset I hope you liked the article. Thank you for reading ### Ready to Add Chat to Your Website? Get started for free. No credit card required. [Start a Free Trial](https://deadsimplechat.com/getstarted) ***
Shard42 (laksa)
Root Hash893329944057161242
Unparsed URLcom,deadsimplechat!/blog/git-revert-how-to-the-complete-guide/ s443