Devops

How to push an empty commit to a remote repository

Sometimes, depending on what you are willing to do, especially when your deployment process is via git, you want to redeploy your application to the remote server, but there are no local changes on the repository to git push.

Empty commits are useful for deployment purposes. It is also important to create a relevant message of your empty commit. As a result, the other team members will understand why such an empty commit exists in history. An example of such a message could be: “Upgrade to Ubuntu 18”.

To create an empty commit use the following command:

git commit --allow-empty -m "Upgrade reason"

Where Upgrade reason should state clearly the reason for this empty commit.

[master (root-commit) bb99ccb] Upgrade reason

With the empty commit created locally, you are now ready to push to the remote origin and trigger all the deployment updates you have already set up.

git push

This technique is followed in order to update the Heroku stack on a production server.

Buy Me A Coffee

Read also the following