You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+28-25
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
-
# git-commit-push-script - Automating Staging, Committing and Pushing to GitHub 👨🏻💻➡️
1
+
# git-commit-push-script - Automating Staging, Committing and Pushing to GitHub with Gemini AI 👨🏻💻➡️
2
2
3
-
Manually typing staging, commit messages, and push commands is repetative. Especially copying the ticket number into the commit message. Save time using this shell script.
3
+
Staging, committing, and pushing code is a repetative manual process. Writing detailed commit messages and adding ticket numbers should be automated using AI. Save time using this shell script powered by Gemini AI.
4
4
5
5
## Table of Contents
6
6
@@ -13,26 +13,28 @@ Manually typing staging, commit messages, and push commands is repetative. Espec
| Terminal or Shell | A terminal or shell for configuring and running the script. |[Download Terminal](https://www.apple.com/macos/terminal/)|
35
36
|`Git Bash`**\*Required for Windows**| Git Bash provides a Unix command line emulator for windows which can be used to run Git, shell commands, and much more. |[Download Git Bash](https://gitforwindows.org/)|
37
+
| Google Gemini API Key | A Gemini API key is required to use Gemini AI to generate commit messages. |[Get Gemini API Key](https://www.getgemini.ai/)|
alias cm='bash /path/to/git-commit-push-script/git-commit-push-script.sh'
61
63
```
62
64
63
-
5. Reload the terminal or shell configuration by running the following command:
65
+
5. Add your Gemini API key to your bash or zsh configuration file (e.g., .zshrc or .bash_profile).
66
+
67
+
```shell
68
+
export GEMINI_API_KEY=<your-gemini-api-key>
69
+
```
70
+
71
+
72
+
6. Reload the terminal or shell configuration by running the following command:
64
73
65
74
```shell
66
75
source~/.zshrc
@@ -70,33 +79,27 @@ source ~/.bash_profile
70
79
71
80
## Usage
72
81
73
-
6. Test the script by running the following command from a Git repository directory with a Jira ticket branch.
82
+
7. Test the script by running the following command from a Git repository directory with a Jira ticket branch (Example - `TEST-1234-Your-GitHub-Branch`).
74
83
75
84
```shell
76
85
cm
77
86
```
78
87
79
-
7. Enter your commit message when prompted.
80
-
81
-
```shell
82
-
Enter commit message: <Enter your commit message here>
83
-
```
84
-
85
-
8. The script will stage, commit with the ticket prefix, and push the changes to the remote branch.
88
+
9. The script will stage, request the commit message from Gemini with the `git diff`, commit with the ticket prefix and message, and push the changes to the remote branch.
86
89
87
90
```shell
88
-
Enter commit message: Test message
89
-
Commit message: CRS-12345 - Test message
90
-
[CRS-12345-Git-Script-Test be6fe58] CRS-12345 - Test message
91
-
1 file changed, 2 insertions(+), 1 deletion(-)
91
+
[TEST-1234 f94df31] TEST-1234 Fix: Remove unnecessary text from Gemini prompt
92
+
1 file changed, 1 insertion(+), 1 deletion(-)
93
+
Branch 'TEST-1234' exists on remote. Pushing changes.
Copy file name to clipboardExpand all lines: git-commit-push-script.sh
+1-1
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ diff=$(git diff --cached)
17
17
diff=$(echo $diff| sed 's/\\/\\\\/g'| sed 's/"/\\"/g'| sed 's/\n/\\n/g')
18
18
19
19
# Prepare the Gemini API request
20
-
gemini_request='{"contents":[{"parts":[{"text": "Write a git commit message (commit message title 72 character maximum and commit message summary 50 character maxiumum) for the following git diff: '"$diff"' The format should be as follows (without titles): <commit message title> (2 new lines) <commit message summary>"}]}]}'
20
+
gemini_request='{"contents":[{"parts":[{"text": "Write a git commit message (commit message title 72 character maximum and commit message summary 50 character maxiumum) for the following git diff: '"$diff"' The format should be as follows (without titles, back ticks, or markdown fomatting): <commit message title> (2 new lines) <commit message summary>"}]}]}'
0 commit comments