If we wanted to revert back to another commit, we could specify the hash value for that commit. In this case, we specified HEAD, which reverts our repository to the last commit. The git revert command needs a commit reference to execute. This means that we still have a complete history of all the commits we pushed to our repository. Instead of deleting our last commit, the git revert command created a new commit that has undone the changes of the previous commit. Our commit history now lists three commits. The syntax for the git revert command is as follows:ī66c29a8c4c226fa9ae8cd8f9e086c0a73e6ecfe (HEAD -> master) revert author order commit "docs: Update order of authors by contributions"Ħf52d877873e7d3b52c929647384dfdf2488da22 docs: Update order of authors by contributionsĥ7d763663e619088159bb7629243456f88feab79 docs: Update README.md with author info Instead of manually making the changes you need to make to your last commit, you can revert your commit and push a new one to the codebase. You should use the git revert command in situations where you want to reverse your last commit. Rather than deleting a commit entirely, it allows you to revert a repository to another commit, so you can still keep an accurate record of every commit you have pushed to a repository. The git revert command is useful because it allows you to preserve the project history of a repository. However, instead of deleting a commit from a project, the git revert command finds the changes between the last two commits and creates a new commit that reverses those changes. This will give you another chance to push your commits in git by reverting the last commit.Ī commit. In this scenario, you may want to revert your repository to the state it was in before you pushed the commit. Instead of committing both of these changes at the same time, you wanted to include them in two separate commits. This means that your commit includes both a bug fix and a new feature, which may be confusing for other collaborators on a project to understand. When you commit the bug fix, you also notice that you have committed the working directory for the new feature you are developing. Sometimes, when you are working with a Git repository, you may notice that you’ve made a mistake in your commit.įor instance, suppose you have just finished working on a new feature, and you’ve realized that there is a bug that needs to be fixed. By the end of reading this tutorial, you’ll be an expert at reverting code using the git revert commit command. This tutorial will discuss, with examples, reverting code and how to use the git revert command to revert your code. , and you consent to receive offers and opportunities from Career Karma by telephone, text message, and email. Get Your Coding Bootcamp Sponsored by Your EmployerĬareer Karma matches you with top tech bootcampsĪccess exclusive scholarships and prep courses.Education Stipends for Coding Bootcamps. Best Coding Bootcamp Scholarships and Grants.Ultimate Guide to Coding Bootcamp Loans.Best Free Bootcamps and Coding Training.Best Online Coding Bootcamps and Courses.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |