đŸ•ˇī¸ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 32 (from laksa081)

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
3 days 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.freecodecamp.org/news/git-revert-commit-how-to-undo-the-last-commit/
Last Crawled2026-04-06 08:00:01 (3 days ago)
First Indexed2021-08-31 22:33:00 (4 years ago)
HTTP Status Code200
Meta TitleGit Revert Commit – How to Undo the Last Commit
Meta DescriptionSay you're working on your code in Git and something didn't go as planned. So now you need to revert your last commit. How do you do it? Let's find out! There are two possible ways to undo your last commit. We'll look at both of them in this article....
Meta Canonicalnull
Boilerpipe Text
Say you're working on your code in Git and something didn't go as planned. So now you need to revert your last commit. How do you do it? Let's find out! There are two possible ways to undo your last commit. We'll look at both of them in this article. The revert command The revert command will create a commit that reverts the changes of the commit being targeted. You can use it to revert the last commit like this: git revert <commit to revert> You can find the name of the commit you want to revert using [git log](https://www.freecodecamp.org/news/git-log-command/) . The first commit that's described there is the last commit created. Then you can copy from there the alphanumerical name and use that in the revert command. In this image, each circe represents a commit. The reset command You can also use the reset command to undo your last commit. But be careful – it will change the commit history, so you should use it rarely. It will move the HEAD, the working branch, to the indicated commit, and discard anything after: git reset --soft HEAD~ 1 The --soft option means that you will not lose the uncommitted changes you may have. In this image, each circle represents a commit. If you want to reset to the last commit and also remove all unstaged changes, you can use the --hard option: git reset --hard HEAD~ 1 This will undo the latest commit, but also any uncommitted changes. In this image, each circle represents a commit. Should You Use reset or revert in Git? You should really only use reset if the commit being reset only exists locally. This command changes the commit history and it might overwrite history that remote team members depend on. revert instead creates a new commit that undoes the changes, so if the commit to revert has already been pushed to a shared repository, it is best to use revert as it doesn't overwrite commit history. Conclusion You have learned two ways to undo the last commit and also when it's best to use one over the other. Now if you notice that your last commit introduces a bug or should have not been committed you know how to fix that! Learn to code for free. freeCodeCamp's open source curriculum has helped more than 40,000 people get jobs as developers. Get started
Markdown
[![freeCodeCamp.org](https://cdn.freecodecamp.org/platform/universal/fcc_primary.svg)](https://www.freecodecamp.org/news/) Menu Menu - [Forum](https://forum.freecodecamp.org/) - [Curriculum](https://www.freecodecamp.org/learn) [Donate](https://www.freecodecamp.org/donate/) [Learn to code — free 3,000-hour curriculum](https://www.freecodecamp.org/) August 31, 2021 / [\#Git](https://www.freecodecamp.org/news/tag/git/) # Git Revert Commit – How to Undo the Last Commit ![Ilenia Magoni](https://cdn.hashnode.com/res/hashnode/image/upload/v1709312068969/41d24c7e-37ea-4383-a202-a64a27013eaa.jpeg) [Ilenia Magoni](https://www.freecodecamp.org/news/author/uccellino95/) ![Git Revert Commit – How to Undo the Last Commit](https://www.freecodecamp.org/news/content/images/size/w2000/2021/08/pexels-siegfried-poepperl-8778445--1-.jpg) Say you're working on your code in Git and something didn't go as planned. So now you need to revert your last commit. How do you do it? Let's find out\! There are two possible ways to undo your last commit. We'll look at both of them in this article. ## The `revert` command The `revert` command will create a commit that reverts the changes of the commit being targeted. You can use it to revert the last commit like this: ``` git revert <commit to revert> ``` You can find the name of the commit you want to revert using `[git log](https://www.freecodecamp.org/news/git-log-command/)`. The first commit that's described there is the last commit created. Then you can copy from there the alphanumerical name and use that in the `revert` command. ![A diagram showing that the git revert command creates a new commit to revert previous changes.](https://www.freecodecamp.org/news/content/images/2021/08/image-117.png) *In this image, each circe represents a commit.* ## The `reset` command You can also use the `reset` command to undo your last commit. But be careful – it will change the commit history, so you should use it rarely. It will move the HEAD, the working branch, to the indicated commit, and discard anything after: ``` git reset --soft HEAD~1 ``` The `--soft` option means that you will not lose the uncommitted changes you may have. ![A diagram showing that git reset --soft will change your commit history, but will keep any unstaged changes you have.](https://www.freecodecamp.org/news/content/images/2022/08/git-reset-soft.png) *In this image, each circle represents a commit.* If you want to reset to the last commit and also remove all unstaged changes, you can use the `--hard` option: ``` git reset --hard HEAD~1 ``` This will undo the latest commit, but also any uncommitted changes. ![A diagram showing that git reset --hard will change your commit history, but will also remove any unstaged changes you have.](https://www.freecodecamp.org/news/content/images/2021/08/image-112.png) *In this image, each circle represents a commit.* ## Should You Use `reset` or `revert` in Git? You should really only use `reset` if the commit being reset only exists locally. This command changes the commit history and it might overwrite history that remote team members depend on. `revert` instead creates a *new commit* that undoes the changes, so if the commit to revert has already been pushed to a shared repository, it is best to use `revert` as it doesn't overwrite commit history. # Conclusion You have learned two ways to undo the last commit and also when it's best to use one over the other. Now if you notice that your last commit introduces a bug or should have not been committed you know how to fix that\! *** ![Ilenia Magoni](https://cdn.hashnode.com/res/hashnode/image/upload/v1709312068969/41d24c7e-37ea-4383-a202-a64a27013eaa.jpeg) [Ilenia Magoni](https://www.freecodecamp.org/news/author/uccellino95/) Read [more posts](https://www.freecodecamp.org/news/author/uccellino95/). *** If this article was helpful, share it. Learn to code for free. freeCodeCamp's open source curriculum has helped more than 40,000 people get jobs as developers. [Get started](https://www.freecodecamp.org/learn) ADVERTISEMENT freeCodeCamp is a donor-supported tax-exempt 501(c)(3) charity organization (United States Federal Tax Identification Number: 82-0779546) Our mission: to help people learn to code for free. We accomplish this by creating thousands of videos, articles, and interactive coding lessons - all freely available to the public. Donations to freeCodeCamp go toward our education initiatives, and help pay for servers, services, and staff. You can [make a tax-deductible donation here](https://www.freecodecamp.org/donate/). ## Trending Books and Handbooks - [REST APIs](https://www.freecodecamp.org/news/build-consume-and-document-a-rest-api/) - [Clean Code](https://www.freecodecamp.org/news/how-to-write-clean-code/) - [TypeScript](https://www.freecodecamp.org/news/learn-typescript-with-react-handbook/) - [JavaScript](https://www.freecodecamp.org/news/learn-javascript-for-beginners/) - [AI Chatbots](https://www.freecodecamp.org/news/how-to-build-an-ai-chatbot-with-redis-python-and-gpt/) - [Command Line](https://www.freecodecamp.org/news/command-line-for-beginners/) - [GraphQL APIs](https://www.freecodecamp.org/news/building-consuming-and-documenting-a-graphql-api/) - [CSS Transforms](https://www.freecodecamp.org/news/complete-guide-to-css-transform-functions-and-properties/) - [Access Control](https://www.freecodecamp.org/news/how-to-build-scalable-access-control-for-your-web-app/) - [REST API Design](https://www.freecodecamp.org/news/rest-api-design-best-practices-build-a-rest-api/) - [PHP](https://www.freecodecamp.org/news/the-php-handbook/) - [Java](https://www.freecodecamp.org/news/the-java-handbook/) - [Linux](https://www.freecodecamp.org/news/learn-linux-for-beginners-book-basic-to-advanced/) - [React](https://www.freecodecamp.org/news/react-for-beginners-handbook/) - [CI/CD](https://www.freecodecamp.org/news/learn-continuous-integration-delivery-and-deployment/) - [Docker](https://www.freecodecamp.org/news/the-docker-handbook/) - [Golang](https://www.freecodecamp.org/news/learn-golang-handbook/) - [Python](https://www.freecodecamp.org/news/the-python-handbook/) - [Node.js](https://www.freecodecamp.org/news/get-started-with-nodejs/) - [Todo APIs](https://www.freecodecamp.org/news/build-crud-operations-with-dotnet-core-handbook/) - [JavaScript Classes](https://www.freecodecamp.org/news/how-to-use-classes-in-javascript-handbook/) - [Front-End Libraries](https://www.freecodecamp.org/news/front-end-javascript-development-react-angular-vue-compared/) - [Express and Node.js](https://www.freecodecamp.org/news/the-express-handbook/) - [Python Code Examples](https://www.freecodecamp.org/news/python-code-examples-sample-script-coding-tutorial-for-beginners/) - [Clustering in Python](https://www.freecodecamp.org/news/clustering-in-python-a-machine-learning-handbook/) - [Software Architecture](https://www.freecodecamp.org/news/an-introduction-to-software-architecture-patterns/) - [Programming Fundamentals](https://www.freecodecamp.org/news/what-is-programming-tutorial-for-beginners/) - [Coding Career Preparation](https://www.freecodecamp.org/news/learn-to-code-book/) - [Full-Stack Developer Guide](https://www.freecodecamp.org/news/become-a-full-stack-developer-and-get-a-job/) - [Python for JavaScript Devs](https://www.freecodecamp.org/news/learn-python-for-javascript-developers-handbook/) ## Mobile App - [![Download on the App Store](https://cdn.freecodecamp.org/platform/universal/apple-store-badge.svg)](https://apps.apple.com/us/app/freecodecamp/id6446908151?itsct=apps_box_link&itscg=30200) - [![Get it on Google Play](https://cdn.freecodecamp.org/platform/universal/google-play-badge.svg)](https://play.google.com/store/apps/details?id=org.freecodecamp) ## Our Charity [Publication powered by Hashnode](https://hashnode.com/) [About](https://www.freecodecamp.org/news/about/) [Alumni Network](https://www.linkedin.com/school/free-code-camp/people/) [Open Source](https://github.com/freeCodeCamp/) [Shop](https://www.freecodecamp.org/news/shop/) [Support](https://www.freecodecamp.org/news/support/) [Sponsors](https://www.freecodecamp.org/news/sponsors/) [Academic Honesty](https://www.freecodecamp.org/news/academic-honesty-policy/) [Code of Conduct](https://www.freecodecamp.org/news/code-of-conduct/) [Privacy Policy](https://www.freecodecamp.org/news/privacy-policy/) [Terms of Service](https://www.freecodecamp.org/news/terms-of-service/) [Copyright Policy](https://www.freecodecamp.org/news/copyright-policy/)
Readable Markdown
![Git Revert Commit – How to Undo the Last Commit](https://www.freecodecamp.org/news/content/images/size/w2000/2021/08/pexels-siegfried-poepperl-8778445--1-.jpg) Say you're working on your code in Git and something didn't go as planned. So now you need to revert your last commit. How do you do it? Let's find out\! There are two possible ways to undo your last commit. We'll look at both of them in this article. ## The `revert` command The `revert` command will create a commit that reverts the changes of the commit being targeted. You can use it to revert the last commit like this: ``` git revert <commit to revert> ``` You can find the name of the commit you want to revert using `[git log](https://www.freecodecamp.org/news/git-log-command/)`. The first commit that's described there is the last commit created. Then you can copy from there the alphanumerical name and use that in the `revert` command. ![A diagram showing that the git revert command creates a new commit to revert previous changes.](https://www.freecodecamp.org/news/content/images/2021/08/image-117.png) *In this image, each circe represents a commit.* ## The `reset` command You can also use the `reset` command to undo your last commit. But be careful – it will change the commit history, so you should use it rarely. It will move the HEAD, the working branch, to the indicated commit, and discard anything after: ``` git reset --soft HEAD~1 ``` The `--soft` option means that you will not lose the uncommitted changes you may have. ![A diagram showing that git reset --soft will change your commit history, but will keep any unstaged changes you have.](https://www.freecodecamp.org/news/content/images/2022/08/git-reset-soft.png) *In this image, each circle represents a commit.* If you want to reset to the last commit and also remove all unstaged changes, you can use the `--hard` option: ``` git reset --hard HEAD~1 ``` This will undo the latest commit, but also any uncommitted changes. ![A diagram showing that git reset --hard will change your commit history, but will also remove any unstaged changes you have.](https://www.freecodecamp.org/news/content/images/2021/08/image-112.png) *In this image, each circle represents a commit.* ## Should You Use `reset` or `revert` in Git? You should really only use `reset` if the commit being reset only exists locally. This command changes the commit history and it might overwrite history that remote team members depend on. `revert` instead creates a *new commit* that undoes the changes, so if the commit to revert has already been pushed to a shared repository, it is best to use `revert` as it doesn't overwrite commit history. ## Conclusion You have learned two ways to undo the last commit and also when it's best to use one over the other. Now if you notice that your last commit introduces a bug or should have not been committed you know how to fix that\! *** *** Learn to code for free. freeCodeCamp's open source curriculum has helped more than 40,000 people get jobs as developers. [Get started](https://www.freecodecamp.org/learn)
Shard32 (laksa)
Root Hash13723046482134587832
Unparsed URLorg,freecodecamp!www,/news/git-revert-commit-how-to-undo-the-last-commit/ s443