
There it shows 2 lines are removed and 1 line is added. This had the error, that's why we reverted, which created the new commit, see the first one in the screenshot. In the second commit (starting with 3db911….), which is the commit before revert, see that one line is removed and two lines are added, which is from when we wanted to optimize the code for a personalized message.
Git it n git Patch#
The -p is for seeing the patch created by the commit and -2 is to limit the output to the last 2 commits. Revert is useful because it automatically reverses the changes, so you don't need to do it manually. Here, the history of changes is not modified, but it keeps a record of everything that happens, good commit, bad commit, and then the reverted commit. So it cancels out the bad commit, and basically, the net effect is just like going back to the previous version before your feature improvement. What revert does is create a new commit with the inverse of the changes you made in the latest commit, which means whatever lines were added will be removed, removed lines will be added, and a new commit will be made. I described the scenario above for ease of understanding that you rollback to the previous version. Here, we will use the git revert command. There are different ways to rollback in Git. And during that time, you can fix the issue, and when it works properly, you can again deploy the new feature. So Git lets you rollback to the previous commit where everything was working properly so that those instances of the code can be deployed for the website and users don't face any problems. This may usually take a lot of time, and you can't bear losses during that time you put towards resolving the error.
Git it n git update#
But it was working properly in the previous version(before you made the changes).🙆♂️ So now what? You will need to identify the bug, rectify, test, and again update the website. After some days, you find out that your code had some error that doesn't work properly on a certain use case, like handling a string of more than 100 characters. After you finish improving the feature, you made the commit with the updated changes (feature improvement code) and released the website update.

The most recent commit, which is there, has all the features bug-free. Say you are working on a particular feature improvement of a website. This means the previous commit contains some changes, and the latest commits contain some new changes but are not limited to a feature update, bug fixes, etc. Every commit made is the latest version of the changes made to the files in that repo.
