From 2c0ba554cd914e5c03853a05da57237d22c0e11a Mon Sep 17 00:00:00 2001 From: Isabelle Viktoria Maciohsek Date: Sun, 4 Apr 2021 20:55:26 +0300 Subject: [PATCH] Add commit variants --- snippets/commit-without-hooks.md | 19 +++++++++++++++++++ snippets/create-commit.md | 1 + snippets/create-empty-commit.md | 17 +++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 snippets/commit-without-hooks.md create mode 100644 snippets/create-empty-commit.md diff --git a/snippets/commit-without-hooks.md b/snippets/commit-without-hooks.md new file mode 100644 index 000000000..1d4c99025 --- /dev/null +++ b/snippets/commit-without-hooks.md @@ -0,0 +1,19 @@ +--- +title: Commit without running git hooks +tags: commit,intermediate +--- + +Creates a new commit skipping the pre-commit and commit-msg hooks. + +- Use `git commit --no-verify -m ` to commit staged changes without running git hooks. + +```sh +git commit --no-verify -m +``` + +```sh +# Make some changes to files, ones that your precommit hook might not allow +git add . +git commit --no-verify -m "Unsafe commit" +# Creates a commit with the message "Unsafe commit", without running git hooks +``` diff --git a/snippets/create-commit.md b/snippets/create-commit.md index 95eaf6e91..53a18f22d 100644 --- a/snippets/create-commit.md +++ b/snippets/create-commit.md @@ -12,6 +12,7 @@ git commit -m ``` ```sh +# Make some changes to files git add . git commit -m "Fix the network bug" # Creates a commit with the message "Fix the network bug" diff --git a/snippets/create-empty-commit.md b/snippets/create-empty-commit.md new file mode 100644 index 000000000..d803ca84c --- /dev/null +++ b/snippets/create-empty-commit.md @@ -0,0 +1,17 @@ +--- +title: Create an empty commit +tags: commit,beginner +--- + +Creates an empty commit. + +- Use `git commit --allow-empty -m ` to create an empty commit with the provided ``. + +```sh +git commit --allow-empty -m +``` + +```sh +git commit --allow-empty -m "Empty commit" +# Creates an empty commit with the message "Empty commit" +```