TIL: How to create an empty Pull Request on GitHub

December 30, 2021 - 1 minute read -
TIL git

TLDR:

git commit --allow-empty -m "empty commit to create PR to start discussion"

I sometimes want to create a Pull Request(PR) to start a discussion without any code. Other times, I want to create a PR to act as the base for upcoming changes to be merged. But GitHub doesn’t allow creating a new PR if there are no differences between the branches.

I found the solution in this StackOverflow answer. Git allows us to create an empty commit via the flag --allow-empty ref.

The following command is required on the branch from which you expect to create the PR

git commit --allow-empty -m "empty commit to create PR to start discussion"

After pushing that commit to the remote branch, I was was able to create the PR.