git commit --allow-empty

Following on from the work I recently did with the reusable workflows, I thought I'd share a quick git command that I found that made my life easier while testing the workflows.

To test changes made in the reusable workflow repository I would need to commit and push a change from the calling repository in order to trigger the latest workflow changes.

This could be done by adding and removing a newline in a file - but git provides a cleaner way of achiving the same thing without having to modify any files:

git commit —allow-empty

This git command that allows you to create a commit and push to the repository with no changes to the files - perfect for my example above where I didn't need to make a change to the calling repository - I just needed to trigger the workflow to run with the new changes made in the reusable workflow.

You can then add in a message like you would an ordinary commit, in the example below I've added a message to show that the commit was made to trigger the workflow:

git commit —allow-empty -m "Trigger workflow”

Did you know about this git command, or think you can find a way to use this in the future? Let me know in the comments below.

Avatar for Kera Cudmore

Written by Kera Cudmore

Junior Software Developer at the Met Office | Code Institute Alumna.

Loading

Fetching comments

Hey! 👋

Got something to say?

or to leave a comment.