đŸ•ˇī¸ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 103 (from laksa156)

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
1 day ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0.1 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://www.geeksforgeeks.org/git/how-to-back-commit-in-git/
Last Crawled2026-04-10 21:50:58 (1 day ago)
First Indexed2025-07-03 11:18:55 (9 months ago)
HTTP Status Code200
Meta TitleHow to Back Commit in Git? - GeeksforGeeks
Meta DescriptionYour All-in-One Learning Portal: GeeksforGeeks is a comprehensive educational platform that empowers learners across domains-spanning computer science and programming, school education, upskilling, commerce, software tools, competitive exams, and more., Your All-in-One Learning Portal. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
Meta Canonicalnull
Boilerpipe Textnull
Markdown
[![geeksforgeeks](https://media.geeksforgeeks.org/gfg-gg-logo.svg)](https://www.geeksforgeeks.org/) - Courses - Tutorials - Interview Prep - [Git Tutorial](https://www.geeksforgeeks.org/git/git-tutorial/) - [Interview Questions](https://www.geeksforgeeks.org/git/git-interview-questions-and-answers/) - [Exercises](https://www.geeksforgeeks.org/git/git-exercise/) - [Cheat Sheet](https://www.geeksforgeeks.org/git/git-cheat-sheet/) - [Bash](https://www.geeksforgeeks.org/git/working-on-git-bash/) - [GitHub](https://www.geeksforgeeks.org/git/introduction-to-github/) - [Branch](https://www.geeksforgeeks.org/git/introduction-to-git-branch/) - [Merge](https://www.geeksforgeeks.org/git/git-merge-and-merge-conflict/) - [WorkFlow](https://www.geeksforgeeks.org/git/git-workflow-etiquettes/) - [Hooks](https://www.geeksforgeeks.org/git/git-hooks/) - [LFS](https://www.geeksforgeeks.org/git/git-lfs-large-file-storage/) - [Rebase](https://www.geeksforgeeks.org/git/rebasing-of-branches-in-git/) # How to Back Commit in Git? Last Updated : 23 Jul, 2025 In this article, we are covering how to undo commits in [Git](https://www.geeksforgeeks.org/git/what-is-a-git-repository/). Sometimes, you might make mistakes or realize you need to revert changes you made in a previous commit. Luckily, Git offers a few ways to undo commits. Table of Content - [Approach 1: Using 'git revert'](https://www.geeksforgeeks.org/git/how-to-back-commit-in-git/#approach-1-using-git-revert) - [Approach 2: Using 'git reset'](https://www.geeksforgeeks.org/git/how-to-back-commit-in-git/#approach-2-using-git-reset) ## Approach 1: Using 'git revert' '****git revert'**** is the generally preferred approach as it creates a new commit that essentially cancels out the changes introduced by the commit you want to undo. The original commit remains in the history, but the new revert commit applies the opposite changes, effectively reversing the effects of the original commit. ****Step 1: Identify the commit to revert**** You'll need the commit hash of the specific commit you want to revert. You can find this using the \`git log\` command. ``` git log ``` This command will display the history of your commits, including their unique hash IDs. ![git-log](https://media.geeksforgeeks.org/wp-content/uploads/20240509133716/git-log.png) Identify the commit to revert ****Step 2: Execute the 'git revert' command**** Once you have the commit hash, use the following command to initiate the revert process. ``` git revert <commit-hash> ``` Replace '****\<commit-hash\>'**** with the ****actual hash ID**** of the commit you want to revert. For example, to revert the most recent commit, you can use: ``` git revert HEAD ``` ![git-revert](https://media.geeksforgeeks.org/wp-content/uploads/20240509135702/git-revert-660.png) Execute the \`git revert\` command ****Step 3: Review and commit the changes**** Git will create a new commit that reverses the changes introduced by the specified commit. You'll be given a chance to review the changes introduced by the revert commit before committing it. ****Step 4: Push the revert commit (if necessary)**** If you've already shared your commits with a ****remote**** repository (e.g., GitHub), you'll need to push the newly created revert commit as well: ``` git push origin <your-branch-name> ``` Replace '\<your-branch-name\>' with the name of the branch you're working on. ## Approach 2: Using 'git reset' 'git reset' offers a more forceful approach to undoing commits. It directly rewrites Git history by moving the ****HEAD**** pointer back to a previous commit. This can be useful if you want to completely remove the unwanted commit from the history. However, use '****git reset'**** cautiously, especially if you've already shared your commits with others, as it can cause issues for collaborators who have pulled the original commit. ****Step 1: Identify the commit to reset to**** Similar to '****git revert'****, you'll need the commit hash of the commit you want to reset to. Use '****git log'**** to find the desired commit hash. ****Step 2: Execute the 'git reset' command**** Use the following command to move the HEAD pointer back to the desired commit. ``` git reset --hard <commit-hash> ``` Replace '\<commit-hash\>' with the ****actual hash ID**** of the commit you want to reset to. ![git-reset](https://media.geeksforgeeks.org/wp-content/uploads/20240509133615/git-reset.png) Execute the 'git reset' command ****Warning: Uncommitted changes will be lost\!**** ****B****efore running '****git reset --hard'****, be aware that any uncommitted changes you have in your working directory will be discarded. ****Step 3: Force push (if necessary, use with caution)**** If you've already pushed the commit you want to remove and need to update the remote repository, you'll have to use a force push. ``` git push --force origin <your-branch-name> ``` ****Warning:**** Force pushing rewrites remote history on the server, potentially causing problems for collaborators who have already pulled the original commit. Use it as a last resort, and communicate the changes clearly to your team. ### Choosing the Right Approach In most cases, \`****git revert****\` is the recommended approach as it creates a clearer audit trail and avoids potentially disruptive rewrites of history. Use \`****git reset****\` cautiously, especially when collaborating with others. ### Additional Considerations - If you have uncommitted changes before using \`****git reset --hard****\`, you can use \`****git stash****\` to save them temporarily and reapply them later. - \`****git revert****\` offers more flexibility as you can inspect the changes introduced by the revert commit before committing it. Comment Article Tags: Article Tags: [Web Technologies](https://www.geeksforgeeks.org/category/web-technologies/) [Git](https://www.geeksforgeeks.org/category/git/) ### Explore [![GeeksforGeeks](https://media.geeksforgeeks.org/auth-dashboard-uploads/gfgFooterLogo.png)](https://www.geeksforgeeks.org/) ![location](https://media.geeksforgeeks.org/img-practice/Location-1685004904.svg) Corporate & Communications Address: A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305) ![location](https://media.geeksforgeeks.org/img-practice/Location-1685004904.svg) Registered Address: K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305 [![GFG App on Play Store](https://media.geeksforgeeks.org/auth-dashboard-uploads/googleplay-%281%29.png)](https://geeksforgeeksapp.page.link/gfg-app)[![GFG App on App Store](https://media.geeksforgeeks.org/auth-dashboard-uploads/appstore-%281%29.png)](https://geeksforgeeksapp.page.link/gfg-app) - Company - [About Us](https://www.geeksforgeeks.org/about/) - [Legal](https://www.geeksforgeeks.org/legal/) - [Privacy Policy](https://www.geeksforgeeks.org/legal/privacy-policy/) - [Contact Us](https://www.geeksforgeeks.org/about/contact-us/) - [Advertise with us](https://www.geeksforgeeks.org/advertise-with-us/) - [GFG Corporate Solution](https://www.geeksforgeeks.org/gfg-corporate-solution/) - [Campus Training Program](https://www.geeksforgeeks.org/campus-training-program/) - Explore - [POTD](https://www.geeksforgeeks.org/problem-of-the-day) - [Job-A-Thon](https://practice.geeksforgeeks.org/events/rec/job-a-thon/) - [Blogs](https://www.geeksforgeeks.org/category/blogs/?type=recent) - [Nation Skill Up](https://www.geeksforgeeks.org/nation-skill-up/) - Tutorials - [Programming Languages](https://www.geeksforgeeks.org/computer-science-fundamentals/programming-language-tutorials/) - [DSA](https://www.geeksforgeeks.org/dsa/dsa-tutorial-learn-data-structures-and-algorithms/) - [Web Technology](https://www.geeksforgeeks.org/web-tech/web-technology/) - [AI, ML & Data Science](https://www.geeksforgeeks.org/machine-learning/ai-ml-and-data-science-tutorial-learn-ai-ml-and-data-science/) - [DevOps](https://www.geeksforgeeks.org/devops/devops-tutorial/) - [CS Core Subjects](https://www.geeksforgeeks.org/gate/gate-exam-tutorial/) - [Interview Preparation](https://www.geeksforgeeks.org/aptitude/interview-corner/) - [Software and Tools](https://www.geeksforgeeks.org/websites-apps/software-and-tools-a-to-z-list/) - Courses - [ML and Data Science](https://www.geeksforgeeks.org/courses/category/machine-learning-data-science) - [DSA and Placements](https://www.geeksforgeeks.org/courses/category/dsa-placements) - [Web Development](https://www.geeksforgeeks.org/courses/category/development-testing) - [Programming Languages](https://www.geeksforgeeks.org/courses/category/programming-languages) - [DevOps & Cloud](https://www.geeksforgeeks.org/courses/category/cloud-devops) - [GATE](https://www.geeksforgeeks.org/courses/category/gate) - [Trending Technologies](https://www.geeksforgeeks.org/courses/category/trending-technologies/) - Videos - [DSA](https://www.geeksforgeeks.org/videos/category/sde-sheet/) - [Python](https://www.geeksforgeeks.org/videos/category/python/) - [Java](https://www.geeksforgeeks.org/videos/category/java-w6y5f4/) - [C++](https://www.geeksforgeeks.org/videos/category/c/) - [Web Development](https://www.geeksforgeeks.org/videos/category/web-development/) - [Data Science](https://www.geeksforgeeks.org/videos/category/data-science/) - [CS Subjects](https://www.geeksforgeeks.org/videos/category/cs-subjects/) - Preparation Corner - [Interview Corner](https://www.geeksforgeeks.org/interview-prep/interview-corner/) - [Aptitude](https://www.geeksforgeeks.org/aptitude/aptitude-questions-and-answers/) - [Puzzles](https://www.geeksforgeeks.org/aptitude/puzzles/) - [GfG 160](https://www.geeksforgeeks.org/courses/gfg-160-series) - [System Design](https://www.geeksforgeeks.org/system-design/system-design-tutorial/) [@GeeksforGeeks, Sanchhaya Education Private Limited](https://www.geeksforgeeks.org/), [All rights reserved](https://www.geeksforgeeks.org/copyright-information/)
Readable Markdownnull
Shard103 (laksa)
Root Hash12046344915360636903
Unparsed URLorg,geeksforgeeks!www,/git/how-to-back-commit-in-git/ s443