Steps to revert a merge commit, add it to a branch, and open a pull request:

Sharat Baradia
1 min readDec 21, 2023

--

a. First, you need to find the commit hash of the merge commit you want to revert. You can do this by using the git log command and finding the commit in the log.

git log

b. Once you have the commit hash, you can revert the merge commit using the git revert command with the -m 1 option followed by the commit hash. The -m 1 option tells Git to revert to the state before the merge.

git revert -m 1 <commit-hash>

c. After reverting the merge commit, you can create a new branch and switch to it using the git checkout -b command followed by the name of the new branch.

git checkout -b <branch-name>

d. Then, you can add the reverted changes to the new branch using the git add command.

git add .

c. Commit the changes with a message describing what you did.

git commit -m "Reverted merge commit"

d. Push the new branch to the remote repository.

git push origin <branch-name>

e. Finally, you can open a pull request on GitHub. Go to the main page of the repository, click on “Pull requests”, then click on “New pull request”. Select the new branch you just pushed to the repository, write a title and description for the pull request, and click on “Create pull request”.

Note: Remember to replace <commit-hash> and <branch-name> with your specific commit hash and branch name.

--

--