Reverting pushed commits
Sometimes faulty commits do make it into the central repository even after amend and rebase. Therefore you can use the below commands
git revert c761f5c // reverts the commit with the specified id
git revert HEAD^ // reverts the second to last commit
git revert develop~4..develop~2 // reverts a whole range of commits
However, If you don’t want to create additional revert commits but only apply the necessary changes to your working tree, you can use the –no-commit/-n option.
git revert -n HEAD
Common Git Problems and Their Fixes
Git is a free and open-source version control system. These days git is being extensively used and therefore this article focuses on some of the common Git tricks that everybody at some point of time requires while working with git or Github.
Sometimes the user makes some mistakes while working on Git which results in the loss of information or wrong information being added. To overcome this problem, Git provides some methods/tricks to roll back or modify the changes that were made wrong or made by mistake. Some of these problems along with their fixes are listed below:
Table of Content
- 1. Edit a commit message
- 2. Undo the local commits
- 3. Reverting pushed commits
- 4. Avoid repeated merge conflicts
- 5. Find a commit that broke something after a merge
Contact Us