Skip to content

Instantly share code, notes, and snippets.

@sdkks
Created February 5, 2023 12:03
Show Gist options
  • Save sdkks/dc00e2a71b0a4988fe91cae051cd4909 to your computer and use it in GitHub Desktop.
Save sdkks/dc00e2a71b0a4988fe91cae051cd4909 to your computer and use it in GitHub Desktop.
Write a multiline git commit message and push directly
c(){
# Stage only modified files
# This ignores new/untracked files
git add -u .
# Use CTRL+D to end commit message
local COMMIT_MSG=$(cat)
if [[ -z "$COMMIT_MSG" ]]; then
return
fi
# Read the commit message from STDIN
echo "$COMMIT_MSG" | git commit -F - &&\
git push -u origin HEAD
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment