diff --git a/README.md b/README.md index ed72765..cdcc71a 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,18 @@ To https://github.com/wesleyscholl/git-commit-push-script.git c76b73c..be6fe58 CRS-12345-Git-Script-Test -> CRS-12345-Git-Script-Test ``` -9. Enjoy the script! +## Troubleshooting + +You may encounter an error from the following command because of the `-S` flag: +```shell +git commit -S -m "" +``` +To resolve this error, remove the `-S` from the command in the `git-commit-push-script.sh` file: +```shell +git commit -m "" +``` +If you want to use the -S flag, configure your Git configuration to use the GPG key for signing commits. +Use the guide here: https://docs.github.com/en/authentication/managing-commit-signature-verification/telling-git-about-your-signing-key ## License This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. diff --git a/git-commit-push-script.sh b/git-commit-push-script.sh index e63423b..097576d 100755 --- a/git-commit-push-script.sh +++ b/git-commit-push-script.sh @@ -12,11 +12,20 @@ ticket=$(echo $base_branch | grep -o -E '([A-Za-z]+-[0-9]{3,}|[A-Za-z]+-[0-9]{3, # Prompt for commit message read -p "Enter commit message: " message -echo "Commit message: $ticket - $message" +echo "Commit message: $ticket $message" # Prepare and execute commit command -git commit -S -m "$ticket - $message" +git commit -S -m "$ticket $message" -# Push changes -git push +# Check if the branch exists on the remote +remote_branch=$(git ls-remote --heads origin $base_branch) +if [ -z "$remote_branch" ]; then + echo "Branch '$base_branch' does not exist on remote. Creating it." + # Push the local branch to the remote, setting the upstream branch + git push --set-upstream origin $base_branch +else + echo "Branch '$base_branch' exists on remote. Pushing changes." + # Push changes to the remote + git push +fi