DEV Community

Malik Benkirane
Malik Benkirane

Posted on

1

A good reason to allow empty git commits

TLDR; workflow with --allow-empty

Think of 1 commit for an original pull request

#1 engage your changes before you actually want to commit
git commit --allow-empty

#2.1 engage changes with care
git commit --allow-empty -av --amend

#2.2 engage changes with determination
git add ${filenames}
git commit --allow-empty --amend

#3 you can always (squash, edit, rebase and more)
git rebase -i ${FETCH_HEAD_or_other_commit}

#4 push your changes
git push ${origin} ${branch}
Enter fullscreen mode Exit fullscreen mode

See also

https://duckduckgo.com/?q=git+commit+no+change
https://stackoverflow.com/questions/12470029/how-to-commit-no-change-and-new-message#12470056

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs