Why does GitHub show me the "compare and pull request" button at the top of the "< > Code" tab some of the time and not others?

Viewed 1280

I read somewhere that it's only when you push a "recent branch" but am unable to find what constitutes a recent branch. I've yet to see a clear and succinct answer regarding when this button will be displayed vs. hidden, even in the Github documentation. Any insight would be greatly appreciated.

1 Answers

As mentioned in "Differences between commits on compare and pull request pages":

The Compare pages show the diff between the tip of the head ref and the current common ancestor (that is, the merge base) of the head and base ref.

So when you have recently pushed a branch (in a non-default branch), there is a diff between HEAD and base refs (base being the default branch of the repository: generally main)

That allows you to initiate a PR, triggering a review process by the one in charge of merging PR to the main branch of the repository.

But if you keep pushing to that branch, or start merging it directly to your main branch... then this option is no longer relevant, and is no longer proposed for that specific branch.

Related