> For the complete documentation index, see [llms.txt](https://gael-boyenval.gitbook.io/debt-collector/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gael-boyenval.gitbook.io/debt-collector/commands-overview/the-compare-command.md).

# The Compare command

Compare 2 git revisions against each other and see the evolution of your debt between them

```shell
debt-collector compare --revision {GIT_REV}
```

where `GIT_REV` is a hash, commit, or a branch where Git is able to checkout onto

{% hint style="info" %}
This command is useful (and has been thought to do so) to publish Pull request reports. It's mostly designed to run in a CI environment, but you can run it from anywhere
{% endhint %}

{% hint style="danger" %}
**DO NOT ABORT EXECUTION :**\
\*\*\*\*As Debt Collector will checkout during the execution of this command, you may find yourself in a different git state if you do not let Debt collector run the command until completion.
{% endhint %}

#### Example :

```
debt-collector compare --revision main
```

In this case, debt-collector will compare the "Main" branch with the current head.

{% hint style="warning" %}
Debt-collector requires you to have a clean history in order to run this command. All changes need to be committed to the current head.\
The revision argument should point to an ancestor of the current head.\
Make sure your local git history is up to date.
{% endhint %}

The compare command will first check the Main branch, then analyse Diff between the ancestor and current head. And then report for every modified files, the debt score evolution, and provide hints on how to reduce the debt further.

### Optional flags :

| flag                    | argument                          | description                                                    |
| ----------------------- | --------------------------------- | -------------------------------------------------------------- |
| **`--revision`**        | `string`: a git revision          | the revision (hash or branch) to compare with the current HEAD |
| **`--rule / -r`**       | `string`: a rule Id               | display results for one specific rule                          |
| **`--tags / -t`**       | `array`: a list of tags           | filter results by rule tags                                    |
| **`--include / -g`**    | `string`: a glob pattern          | override the include configuration                             |
| **`--html-report`**     | `boolean` (default: `false`)      | generate an HTML report                                        |
| **`--common-ancestor`** | `boolean` (default: `true`)       | use the merge-base (common ancestor) for the diff              |
| **`--config / -c`**     | `string`: path to the config file | change the default config path                                 |
| **`--help`**            |                                   | display help                                                   |
