Skip to content

Instantly share code, notes, and snippets.

@dgrebb
Last active June 9, 2024 22:03
Show Gist options
  • Save dgrebb/a2dba6f9a06e43710d5e8f7d9038d96a to your computer and use it in GitHub Desktop.
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
#!/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