The workflow you are using seems: continuous build/deploying for uat
branch, and then merge uat
branch into master
for a new release.
So I will suggest backup current uat
branch, remove the three commits on uat
branch. After merging uat
branch into master
, recovery/reapply the three commits on uat
branch again for next release.
There have two situations for you to change and recovery/reapply uat
branch. You can follow one the below situations you meet.
Situation 1: the three commits are the latest three commits on uat
branch
Assume the commit history looks as below, and the commit D
, E
and F
are the commits for the feature that you decide to postpone for next release.
…---A---B master
…---C---D---E---F uat
You can use below commands to backup current uat
branch and then remove the three commits on uat
branch:
git checkout -b temp uat
git checkout uat
git reset --hard HEAD~3
Then the commit history looks like:
…---A---B master
…---C uat
\
D---E---F temp
And now, you can merge uat
into master
for the new release, so the commit history will be:
…---A---B---G master
/
…---------C uat
\
D---E---F temp
Then you can recovery uat
branch as original by
git checkout uat
git merge temp
git branch -D temp
Then the commit history looks as below, and the three commits D
, E
and F
will apply for next release when merge uat
into master
for next time.
…---A---B---G master
/
…---------C---D---E---F uat
Situation 2: the three commits are not the latest commits, there has other commit(s) after the three commits
Assume the commit history as below, and the commits D
, E
and F
are the commits you want to remove. And there have commits G
and H
after the three commits.
…---A---B master
…---C---D---E---F---G---H uat
To backup current uat
and remove the three commits on uat
branch, you can use below commands:
git checkout -b temp uat
git checkout uat
git rebase --onto uat~5 uat~2 uat
The commit history will be:
…---A---B master
…---C---G'---H' uat
\
D---E---F---G---H temp
After merge uat
into master
, the commit history looks like:
…---A---B------I master
/
…---C---G'---H' uat
\
D---E---F---G---H temp
Then you can re-apply the three commits D
, E
and F
on uat
branch by below commands:
git checkout temp
git reset --hard HEAD~2
git rebase uat temp
git checkout uat
git merge temp
git branch -D temp
Then the commit history will be:
…---A---B------I master
/
…---C---G'---H'---D'---E'---F' uat
And the three commits D'
, E'
and F'
can be release for next time.