Categories
Git

Git reverted branch is now ready to merge again issue

Note:- always rebase your branch with master before you create PR 🙂.

Lets say you have worked on Defect DEF-143 after you have fixed the issue and is ready to merge with PR and branch name DEF-143 , you will merge the code but just before release to production team decide to revert the your branch changes and release it in upcoming release date. 

In this case since branch DEF-143 was merged and reverted , GIT/Bitbucket will remember the commit ID which was merged , so when you try to recreate the PR to merge you will see no code diff 😦😞. 

what should we do? 

Go to your IDE for me it intelliJ terminal or git terminal where you are in your branch . 

git reset –soft HEAD-1

git add .

git commit –amend  

once you have finished your steps above perform git force push and now the PR will show difference in the code clearly.

The same command is used when you have multiple commit in one branch and you want to Squash all the commits with one commit and create PR. 

why the command above works ? 

Because, above ste of command gives you new commit ID and will not confuse GIT/Bitbucket.Â