Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<commit message>"
```
To resolve this error, remove the `-S` from the command in the `git-commit-push-script.sh` file:
```shell
git commit -m "<commit message>"
```
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.
Expand Down
17 changes: 13 additions & 4 deletions git-commit-push-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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