Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Could someone give me a usecase for when an empty commit might be useful?


Annotating the start of a new bulk of work or a new feature. Documenting when you make changes to the project that aren't code related, e.g. "Now using GitHub for issue tracking, closes #1". Communicating with people using your repo, e.g. "Merry Christmas y'all, I'm away for three weeks, if you have any questions please contact Jim".

I'm not saying doing any of these things is good practice but they are use-cases for when an empty commit might make sense.


To tell CI (for example, Jenkins) to rebuild.


You can often trigger a rebuild for such services via their web UI.


To make a commit to a Gist look the same as changes done through the web interface.

Edit: sorry, i was thinking about --allow-empty-message, not --allow empty.


Opening a PR to discuss a new feature before it is built.


You can also do that by just creating an Issue, and then converting it to a Pull Request later with `hub pull-request -i <existing-issue-num>`, when you actually have some code to commit. That uses the software Hub, mentioned in the cheat sheet. Or instead of installing Hub, you can convert the Issue using one of the other methods listed in http://stackoverflow.com/q/4528869/578288.


I don't recommend converting issues to Pull Requests. See the discussion here which goes into details: https://github.com/github/hub/commit/4f70dd126f46dec14fc341c...


I use this constantly. Building a PR up with lot of people watching and involved is pretty amazing. Certainly don't need to all the time, but when working on something sensitive or still ambiguous it's invaluable. So many of my PRs have 50-70 comments by the time they go in.

Amazing review at every step of the way.


Fantastic suggestion! I always disliked opening a PR after my first code change. Will definitely start using this :)


I usually initialize my git repos with an empty commit. Several reasons why this is a good idea (detailed in this blog post - http://kevin.deldycke.com/2010/05/initialize-git-repositorie...)

I have a git alias for the same -

  start = !git init && git commit --allow-empty -m \"chore: empty initial commit\"
Note: That's not my blog.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: