-
-
Save bonelifer/8317c24b5a242727d438101712baf36a to your computer and use it in GitHub Desktop.
alias to create empty commits
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
#!/bin/bash | |
# Function: commit | |
# Description: Commits changes to the current branch with an empty commit message containing the branch name. | |
commit() { | |
# Check if the current directory is within a Git repository | |
if ! git rev-parse --is-inside-work-tree &>/dev/null; then | |
echo "Error: Not in a Git repository. Please navigate to a Git repository directory." | |
return 1 | |
fi | |
# Get the name of the current branch | |
branchName=$(git rev-parse --abbrev-ref HEAD) | |
# Commit changes with an empty commit message containing the branch name | |
git commit --allow-empty -m "Branch name: $branchName" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment