How do I reset the comparison counter between two branches in Azure DevOps?

In Azure DevOps, you have a default and a compare branch.

Our commit strategy is to commit all development to a branch called TEST, and when a task is all done and ready, squash its commits to branch MASTER. We want to keep the detailed commit history on TEST, and a clean history on MASTER.

This leaves the test still ahead of master after a squash commit.

It does not help to merge master back into test. Test will still be ahead, now with +1.

How do I reset the compare counter to say 0 ahead, 0 behind when the files are identical and the same ? (but commit history is obviously different because of the squash commits)

Straightforward answer:

You can’t reset the “ahead/behind” counter to zero in Azure DevOps if the commit histories of the two branches (TEST and MASTER) are different — even if the file contents are identical. Azure DevOps compares commit ancestry, not file content, to calculate the “ahead/behind” status.


What you can do:

If you want Azure DevOps to show “0 ahead, 0 behind”, you must make TEST and MASTER share the same commit history — which conflicts with your goal of keeping detailed commits on TEST and squashed commits on MASTER.


Possible workarounds:

  1. Live with it. Accept that TEST will always show as “ahead” due to its detailed history. It doesn’t affect functionality — it’s just a display difference.
  2. Force reset TEST to MASTER after squash:
  • This will discard the detailed commit history on TEST, so it’s not ideal for you.
git checkout TEST
git reset --hard origin/MASTER
  1. Create temporary feature branches from TEST per task, and use those for squash-merges into MASTER. Keep TEST as a “mirror” of MASTER if needed.

Summary:

There is no supported way to make Azure DevOps show “0 ahead/behind” when two branches have different histories (even if the file trees are the same). The “ahead/behind” status is based purely on commit ancestry.