I am looking for the best way to temporarily remove one past changest(merged from feature branch) from the master branch which is already pushed to the server, considering that I don't want to lose those changes as in the future we shall merge them back to the master.
We are using GIT as a source control tool. Basically when we are working on a new functionality following the flow given below:
- Firstly, we create a new feature branch from the master branch.
- After finishing the coding on the feature branch(there can be multiple commits), do rebase onto master and create Pull Request(PR).
- After PR reviewed, changes are being merged to the master.
The below snapshot is from the master branch which is the result of this command:
git log --graph --decorate --oneline
* e7655f500 Merged PR Z:
|\
| * bc255d318
| * 7d26a7a07
| * a6a46df89
|/
* f1580b24b Merged PR Y:
|\
| * 9363bd302
| * b15ec84dc
| * a37209071
| * 5659763bd
|/
* d9cc23826 Merged PR X:
I want to remove merges came with SHA f1580b24b, so, the master logically should become something like below(of course there can be more changeset regarding revert or other commands on top of SHA e7655f500):
* e7655f500 Merged PR Z:
|\
| * bc255d318
| * 7d26a7a07
| * a6a46df89
|/
* d9cc23826 Merged PR X
I also need to keep below changes somewhere(e.g. a new feature branch) so that in the future I can merge them back to master:
* f1580b24b Merged PR Y:
|\
| * 9363bd302
| * b15ec84dc
| * a37209071
| * 5659763bd
|/
Some day in the future we decide to put back the changes we removed from the master branch (it is possible since that time new merges made to the master):
* f1580b24b Merged PR Y:
|\
| * 9363bd302
| * b15ec84dc
| * a37209071
| * 5659763bd
|/
* f8655f500 Merged PR A:
|\
| * cd255d318
| * 8e26a7a07
|/
* e7655f500 Merged PR Z:
|\
| * bc255d318
| * 7d26a7a07
| * a6a46df89
|/
* d9cc23826 Merged PR X
I might use git revert as an option and in the future un-revert it, but not sure about its impacts on the master branch mainline. Please advise what is the best approach to follow to achieve this?