How to push an empty commit?

Have you ever tried to push a commit to a Git branch without changing any files in order to re-run your integration process? If yes then you are at the right corner.

git commit –allow-empty -m “Message”

Problem

For continuous integ…


This content originally appeared on DEV Community and was authored by simc dev

Have you ever tried to push a commit to a Git branch without changing any files in order to re-run your integration process? If yes then you are at the right corner.

git commit --allow-empty -m “Message”

Problem

For continuous integration, we are using 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.

But today I faced a problem where I needed to re-run my delivery pipeline of a branch without adding any extra space or changing any files in the repository, 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 git commit.

Enough of the problem, let’s jump on to the solution
Pushing a commit with staged files

git add .

git commit -m "changes on app controller"

git push origin master 

The above commands will add all unstaged files and add commit and push the code to the master branch, after that our delivery pipeline will be started.

Once the pipeline process fails or you need to run the process again, you will have to push something to the branch but as I mentioned earlier, we will not make any changes to the files, and even then, We will be able to commit the branch with this command.

Pushing empty commit

git commit --allow-empty -m "rerunning the delivery pipeline"

git push origin master 

After the above commands, you can see that the commit has been pushed to your branch and the delivery pipeline will be started.


This content originally appeared on DEV Community and was authored by simc dev


Print Share Comment Cite Upload Translate Updates
APA

simc dev | Sciencx (2025-10-31T12:58:17+00:00) How to push an empty commit?. Retrieved from https://www.scien.cx/2025/10/31/how-to-push-an-empty-commit-2/

MLA
" » How to push an empty commit?." simc dev | Sciencx - Friday October 31, 2025, https://www.scien.cx/2025/10/31/how-to-push-an-empty-commit-2/
HARVARD
simc dev | Sciencx Friday October 31, 2025 » How to push an empty commit?., viewed ,<https://www.scien.cx/2025/10/31/how-to-push-an-empty-commit-2/>
VANCOUVER
simc dev | Sciencx - » How to push an empty commit?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/10/31/how-to-push-an-empty-commit-2/
CHICAGO
" » How to push an empty commit?." simc dev | Sciencx - Accessed . https://www.scien.cx/2025/10/31/how-to-push-an-empty-commit-2/
IEEE
" » How to push an empty commit?." simc dev | Sciencx [Online]. Available: https://www.scien.cx/2025/10/31/how-to-push-an-empty-commit-2/. [Accessed: ]
rf:citation
» How to push an empty commit? | simc dev | Sciencx | https://www.scien.cx/2025/10/31/how-to-push-an-empty-commit-2/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.