Add commit variants
This commit is contained in:
19
snippets/commit-without-hooks.md
Normal file
19
snippets/commit-without-hooks.md
Normal file
@ -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 <message>` to commit staged changes without running git hooks.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git commit --no-verify -m <message>
|
||||||
|
```
|
||||||
|
|
||||||
|
```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
|
||||||
|
```
|
||||||
@ -12,6 +12,7 @@ git commit -m <message>
|
|||||||
```
|
```
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
# Make some changes to files
|
||||||
git add .
|
git add .
|
||||||
git commit -m "Fix the network bug"
|
git commit -m "Fix the network bug"
|
||||||
# Creates a commit with the message "Fix the network bug"
|
# Creates a commit with the message "Fix the network bug"
|
||||||
|
|||||||
17
snippets/create-empty-commit.md
Normal file
17
snippets/create-empty-commit.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
title: Create an empty commit
|
||||||
|
tags: commit,beginner
|
||||||
|
---
|
||||||
|
|
||||||
|
Creates an empty commit.
|
||||||
|
|
||||||
|
- Use `git commit --allow-empty -m <message>` to create an empty commit with the provided `<message>`.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git commit --allow-empty -m <message>
|
||||||
|
```
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git commit --allow-empty -m "Empty commit"
|
||||||
|
# Creates an empty commit with the message "Empty commit"
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user