> ## Content Index
> Fetch the complete content index at: https://linuxhandbook.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Push an Empty Commit in Git
- URL: https://linuxhandbook.com/git-push-empty-commit/
- Published: 2024-06-19T03:33:34.000Z
- Updated: 2024-06-19T03:33:34.000Z
- Description: Yes, you can totally push an empty commit in Git if you really want to. Here's how to do that.
- Author: Sagar Sharma
- Tags: Using Git

While it sounds ridiculous to push an empty commit in Git, there are several reasons why one would want to do so such as marking a checkpoint. 

The best part is Git allows you to push an empty commit without any trick as all you have to do is use the `--allow-empty` flag while committing:

```
git commit --allow-empty -m "The empty commit"
```

Then you can push it to the main branch:

```
git push origin master
```

Want more details? I got you 😉

## Pushing an empty commit in Git

Most Git users are already aware of how to commit a file in Git you may get confused as if you don't stage any file and try to commit it, then it will tell you "nothing to commit":

![unable to commit empty in git](https://linuxhandbook.com/content/images/2024/02/unable-to-commit-empty-in-git-1.png)

To push an empty commit in [Git](https://www.git-scm.com/?ref=linuxhandbook.com), you have to use the `--allow-empty` flag with the git commit command as shown here:

```
git commit --allow-empty -m "Your message"
```

![Push empty commit in git](https://linuxhandbook.com/content/images/2024/02/Push-empty-commit-in-git.png)

Once you are done with the commit, you can push it to the master remote:

```
git push origin master
```

![push empty commit in git](https://linuxhandbook.com/content/images/2024/02/push-empty-commit-in-git.png)

There you have it! 

## Want to learn Git from scratch? Hear me out!

If [you are new to Git](https://linuxhandbook.com/git/), then you can start by learning [how to create a new branch in Git:](https://linuxhandbook.com/git-create-branch/)

[Create a New Branch in GitIn the Git Beginner’s tutorial, learn how to create a new branch.![](https://linuxhandbook.com/content/images/size/w256h256/2021/08/Linux-Handbook-New-Logo.png)Linux HandbookTeam LHB![](https://linuxhandbook.com/content/images/2022/09/create-branche-in-git.png)](https://linuxhandbook.com/git-create-branch/)

Furthermore, if you want to do the same but on GitHub, then, here's how to [create a new repository in GitHub:](https://linuxhandbook.com/github-create-repository/) 

[How to Create a new Repository in GitHubIn this primer on GitHub, learn to create new repositories. It also answers a few common doubts that arise while creating GitHub repositories.![](https://linuxhandbook.com/content/images/size/w256h256/2021/08/Linux-Handbook-New-Logo.png)Linux HandbookPrakhar Tiwari![](https://linuxhandbook.com/content/images/2023/10/github-create-new-repositories.png)](https://linuxhandbook.com/github-create-repository/)

Finally, here are some [tips for setting up an effective GitHub](https://linuxhandbook.com/github-profile-tips/) student profile:

[7 Tips to Make a Rockstar Student Developer GitHub ProfileTime to enhance the look and feel of your boring default GitHub profile with these tips and suggestions.![](https://linuxhandbook.com/content/images/size/w256h256/2021/08/Linux-Handbook-New-Logo.png)Linux HandbookPrakhar Tiwari![](https://linuxhandbook.com/content/images/2024/01/best-practices-for-rockstar-student-developer-profile.png)](https://linuxhandbook.com/github-profile-tips/)

Let me know what else should I cover from the Git side.