This document addresses scenarios such as below:
- You branched as branch-123 from develop on a repository
- To get your changes tested along with some other branch-345, you merged branch-345 into yours
- When the time came to review your branch-123 against develop, there are changes from branch-345 as well (which isn't yet merged to develop)
- Hence, you need to remove commits from branch-345 to have the PR show only the diff between branch-123 and develop
Assume the git log looks like the following
commit e5d260c2d19c388ed316bc09e62bddd653e746de << THIS IS HEAD
Author: [email protected]
Date: Tue Jun 6 12:10:42 2017 +1000
branch-345 merged changes from 345
commit 06e1549de226ef625f5a433cd97e1a5b8da1a4b3 << THIS IS WHERE YOU WANT IT TO BE
Author: Sudhanshu Mishra <[email protected]>
Date: Fri Jun 2 10:53:00 2017 +1000
branch-123 Changes to fix bug
- Hard reset to your commit before the merge
# WARNING: THIS WILL OVERWRITE HISTORY!!!
git reset --hard 06e1549de22
- Force push to remote
# WARNING: THIS WILL OVERWRITE HISTORY ON REMOTE!!!
git push origin feature/branch-123 --force