π©βπ» Real-World Context: CPQ Workflows and Spec Change Reverts
In CPQ development, it's not unusual to deploy a Spec Change to UAT, feel proud of your work, and then suddenly hear:
"Can you revert that from PROD?"
Rather than manually deleting or commenting out code (π inefficient and error-prone), we do what any self-respecting developer would:
Use git revert
to undo the commits cleanly and traceably.
But then comes the real twist:
Later on, youβre asked to bring the changes backβand Git greets you with:
βMerge request? What merge request? Nothing changed.β
Welcome to the paradox of the reverted feature branch.
β What Went Wrong?
- When you reverted the changes, Git added new commits that undo your work.
- Your original commits are still in history, so Git thinks your feature is already merged.
- Trying to rebase or merge the feature branch again leads to a classic nightmare: π¨ Conflicts everywhere.
β The Solution: Revert the Revert
Letβs walk through it step by step.
π οΈ Step-by-Step Guide
Step 1 β Find the Revert Commit(s)
You can find the commit hash of the revert commit in a couple of ways:
- Within Visual Studio: Open the Git history view to see recent commits, including revert commits. Look for commits with messages like:
Revert "feature/spec-change"
- In Azure DevOps: Navigate to the Completed Pull Request (PR) that contains the revert. Thereβs a Commits tab that lists all commits included in that PRβfind the revert commit here and copy its commit hash.
- Or via Terminal:
git log
Step 2 β Branch From the Original Feature
1.Switch to master and update it:
git checkout master
git pull origin master
2.Checkout your original feature branch:
git checkout feature/spec-change
3.Create a new branch to revert the revert:
git checkout -b feature/revive-spec-change
Step 3 β Perform Your Preferred Stress-Relieving Activity
Take a deep breath and do what helps you relax β walk, grab a coffee, meditate, or if youβre like me,
curse the day you decided to become a developer.
Step 4 β Merge Latest Master Into Your Branch
git merge master
This brings in the revert commits so they become part of your feature branchβs history.
Step 5 β Revert the Revert
You can do this either via command line or Visual Studio:
- Using Git CLI: For a revert of a merge commit use:
git revert -m 1 <revert-commit-hash>
The -m 1
flag tells Git to keep the first parent (usually master).
- Using Visual Studio: In Git History, right-click the revert commit and select Revert.
Step 6 β Handling Multiple Revert Commits
If your original feature had multiple commits reverted individually, you'll have multiple revert commits.
For example, if the original commits were:
Original Commit | Revert Commit |
---|---|
C1 | R1 |
C2 | R2 |
C3 | R3 |
You need to revert these revert commits in descending order (latest first):
git revert <R3>
# If conflicts arise, resolve, commit, then continue
git revert <R2>
git revert <R1>
Reverting them in descending order prevents merge issues that might arise due to dependency between the commits.
Step 7 β Resolving Conflicts During Revert
If you encounter conflicts during any revert:
- Resolve the conflicts manually in your code editor.
- Stage the resolved files:
git add .
- Commit the conflict resolution:
git commit
- Continue with the next revert commit.
Step 8 β Important: Donβt Revert Merge Commits
Merge commits like:
Merge branch 'feature/spec-change' into master
Do not revert these. Only revert the actual commits that contain code changes.
Step 9 β Push and Create a New Merge Request
Once all revert reverts are done, push your branch and create a PR to merge your changes back in:
git push origin feature/revive-spec-change
Then open Azure DevOps and create a new Pull Request for your branch.
π§ββοΈ Final Tips and Summary
Task | Command / Action |
---|---|
Find revert commit | Visual Studio Git History or Azure DevOps PR Commits tab |
Branch from original feature | git checkout -b feature/revive-spec-change |
Merge master | git merge master |
Revert a merge revert commit |
git revert -m 1 <hash> or Visual Studio Revert |
Multiple revert commits | Revert in descending order one by one |
Resolve conflicts | Manual resolve β git add . β git commit
|
Donβt revert merge commits | Ignore these, only revert actual commits |
Push and PR |
git push + create PR in Azure DevOps |
Happy coding! π
Top comments (0)