Last active
June 9, 2024 22:03
-
-
Save dgrebb/a2dba6f9a06e43710d5e8f7d9038d96a to your computer and use it in GitHub Desktop.
Git `gcn!` alias — amend the last commit without prompting to edit or running git hooks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
alias gcn!='f() { | |
if git diff --cached --quiet && git diff --quiet; then | |
printf "No changes to commit\n" | |
else | |
if git diff --cached --quiet; then | |
printf "No files added to staging! Did you forget to run git add?\n" >&2 | |
else | |
git commit --verbose --no-edit --amend --no-verify | |
fi | |
fi | |
}; f' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment