Retrigger CI Build
From time to time I stumble across the task to retrigger a CI build. Often it can be done using the UI of my automation tool, but sometimes simply can't do this. For example because I do not have access to the tool to trigger the build manually or it does not work as expected.
Pushing empty commits
Then the only way to trigger the build is through Git but without making changes to my project. By pushing an empty commit, you can trigger your build without making any changes to the project.
As Git does not allow commits without messages. Also, to push a new commit to the remote repository, it seems line you need to make changes to your project. To avoid this and to push a commit without making any changes yYou can use the following command:
git commit --allow-empty -m "Retrigger CI build manually"
Just like creating a normal commit, except that you add the --allow-empty flag.
If you use this command more often than me it may be an advantage to create a git alias, which allows you to create shortcuts for frequently used Git commands. Instead of writing the full command each time you want to retrigger the ci manually, you could have a shortcut such as git retrigger-ci. For in-depth information about Git aliases check this page..
You can set a new Git alias by running the following command in your terminal:
git config --global alias.retrigger-ci 'commit --allow-empty -m "Retrigger CI build manually"'