Photo by Roman Synkevych 🇺🇦 on Unsplash
Can we push an empty commit?
git commit --allow-empty -m "empty commit"
Git Repo: github.com/syedjafer/empty_commit_tut
Introduction
During our software development, we follow continuous integrations to deploy our code to the dev/QA/prod environment. For continuous integration, we are using Azure/AWS CI/CD delivery pipelines which allow us to build, test and deploy applications on a single push to a specific git branch. It helps us to reduce the manual overhead of deploying code to the server and handle all the actions automatically.
Problem
We might have faced a problem, where we needed to re-run our delivery pipeline of a branch without adding any extra space or changing any files in the repository.
Solution
So I searched for the solution for a while and It turns out that Git is allowing us to push an empty commit without adding any staged files to the branch, by using one option --allow-empty during the git commit.
git commit --allow-empty -m "empty commit"
So we will try to create a scenario to check this working,
1.Let us create a new repository,
2.After the first commit,
3.Empty commit,
4.Verifying the commit details in github,
Conclusion
Thus, from now on we need not to change any files to re-trigger the CI/CD Piplelines.