At times you may want to manually initiate and trigger a build to generate an artifact or kick-start a workflow but it only works when a code commit happens.
If you do not have anything to commit to your git repo, in such cases usually a hack people do is to change a code file (such as a comment line) and add to the staging area and commit-push.
Clean way to perform an empty commit
Make use of the flag --allow-empty with the git commit command,
Example:% git commit --allow-empty -m "Empty commit"
[main 549a3bf] Empty commit
% git log --oneline
549a3bf (HEAD -> main) Empty commit
6ac92d6 4th commit
06250f0 3rd commit
2712514 2nd commit
a3e24f4 1st commit
![Git Cleaner way for an empty Commit Example Git Cleaner way for an empty Commit Example](https://code2care.org/git/perform-an-empty-commit-git-without-anything-in-staging-area/images/Git Cleaner way for an empty Commit Example.png)
Facing issues? Have Questions? Post them here! I am happy to answer!
Author Info:
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
More Posts related to Git,
- Change the default git branch name from master to main
- [Fixed] Git Clone git@github.com: Permission denied (publickey) Could not read from remote repository Fatal error
- [Solution] fatal: not a git repository (or any of the parent directories): .git
- [fix] zsh: command not found: git
- How to Install Git on Windows
- Setup Git + Visual Studio Code Tutorial
- How to undo last Git Commit on Local Repository?
- Install GitHub Command Line Tool on Mac
- How to Create a Git Branch in 6 Different ways
- Fix Git: Warning: could not find UI helper GitHub.UI on Windows
- Git Config Command - A Deep Dive
- Step-by-Step: How to delete a git branch from local as well as remote origin
- How to Add Git Bash Option to Windows Terminal List
- Command to Clone Repository Using Git Bash
- How to remove or unstage a file from git staged area
- Get the file location of git config values
- GitHub: How to Search Code
- How to check your installed version of Git
- Fix: error: src refspec master does not match any failed to push some refs to Git
- Git: Step-by-Step - How to Push Local Brach to GitHub
- How to Merge Branch into Master Branch
- fix fatal: --local can only be used inside a git repository error
- Fix: Git Pull Error: unable to resolve reference refs/remotes/origin/master: reference broken
- Change the default diff or commit editor for git
- Git Fix: fatal: refusing to merge unrelated histories Error
More Posts:
- What is Microsoft 365 Message You are using more licenses on your trial than what you will purchase once the free trial ends. - Microsoft
- Mac: Sign in Required We cant upload or download your changes because your cached credentials have expired [Word Excel] - Windows
- Java Jackson ObjectMapper Class with Examples - Java
- Calculate Area of Trapezoid - C-Program
- How to open CMD for current file/folder location in Notepad++ - NotepadPlusPlus
- How to Change or Set a new Password for your Wi-Fi Router - HowTos
- Create simple struts2 project using maven commands - Java
- How to always show Bookmarks bar on Google Chrome Browser - Chrome