-
-
Save ignat-one/6910f35601c96ac2bdac58cfa890bce7 to your computer and use it in GitHub Desktop.
git add . && git commit -m "<current branch name> <commit message>"
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
function gcommit() { | |
# Retrieve the current branch name | |
local branch_name=$(git rev-parse --abbrev-ref HEAD) | |
# Check if we successfully retrieved a branch name | |
if [ -z "$branch_name" ]; then | |
echo "Failed to detect Git branch name." | |
return 1 | |
fi | |
# Add all changes and commit them | |
git add . | |
if git commit -m "$branch_name $1"; then | |
echo "Successfully committed on branch $branch_name." | |
else | |
echo "Commit failed." | |
return 1 | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment