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
+49-23Lines changed: 49 additions & 23 deletions
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 with Gemini AI 👨🏻💻➡️
1
+
# git-commit-push-script - Automating Staging, Committing and Pushing to GitHub with Ollama and Mistral AI 👨🏻💻➡️
2
2
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.
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 Ollama and Mistral AI.
4
4
5
5
## Table of Contents
6
6
@@ -16,8 +16,10 @@ Staging, committing, and pushing code is a repetative manual process. Writing de
| Git Staging | Staging any modified files for commit using `git add -A`. |
18
18
| Git Commit Message Ticket Title | Copying the ticket number of the Jira ticket as the commit message prefix. Example: `[CRS-12345]`. |
19
-
| Writing Commit Messages Using AI | The script uses Gemini AI to generate commit messages using `git diff --cached`. |
19
+
| Writing Commit Messages Using AI | The script uses Ollama and Mistral AI to generate commit messages using `git diff --cached`. |
20
20
| Git Commit | Committing staged files with the commit message using `git commit -S -m "<commit message>"`. |
21
+
| Entering SSH Passphrase | If the SSH key is passphrase protected, the script will enter the passphrase automatically using an env variable (Ex. `GIT_SSH_PASSPHRASE`). |
22
+
| Git Fetch & Pull | Pulling the latest changes from the remote branch with `git fetch origin <branch>` & `git pull`. |
21
23
| Git Push | Pushing local commits to remote branch with `git push`. |
22
24
| Git Push Retry (Pull & Push) | If a push fails, the script will `git pull` from the remote branch and push again. |
23
25
@@ -27,8 +29,11 @@ Staging, committing, and pushing code is a repetative manual process. Writing de
| Terminal or Shell | A terminal or shell for configuring and running the script. |[Download Terminal](https://www.apple.com/macos/terminal/)|
29
31
|`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/)|
30
-
| 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/)|
31
-
| Alias Command | The alias command to be used for the script: `cm`. | Bash profile (`.zshrc` or `.bash_profile`) |
32
+
| Ollama | Ollama must be installed and configured. |[Get Ollama](https://ollama.com/)|
33
+
| Mistral AI Model | The Mistral AI model must be downloaded and running locally. Example: `ollama pull mistral`|[Get Mistral](https://ollama.com/models/mistral)|
34
+
| Alias Command **(optional)**| The alias command to be used for the script: `cm`. | Bash profile (`.zshrc` or `.bash_profile`) |
35
+
| SSH Key **(optional)**| If you want to use SSH for Git operations, you will need to configure your SSH key. |[Git SSH Key Guide](https://docs.github.com/en/authentication/connecting-to-github-with-ssh)|
36
+
| GPG Key **(optional)**| If you want to sign your commits, you will need to configure your GPG key in Git. |[Git GPG Key Guide](https://docs.github.com/en/authentication/managing-commit-signature-verification/telling-git-about-your-signing-key)|
alias cm='bash /path/to/git-commit-push-script/git-commit-push-script.sh'
57
62
```
58
63
59
-
5.Add your Gemini API key to your bash or zsh configuration file (e.g., .zshrc or .bash_profile).
64
+
5.Install and start the Ollama server by running the following command:
60
65
61
66
```shell
62
-
export GEMINI_API_KEY=<your-gemini-api-key>
67
+
homebrew install ollama
68
+
# AND/OR #
69
+
ollama serve
63
70
```
71
+
6. Download the Mistral AI model by running the following command:
64
72
73
+
```shell
74
+
ollama pull mistral
75
+
```
65
76
66
-
6. Reload the terminal or shell configuration by running the following command:
77
+
7. Reload the terminal or shell configuration by running the following command:
67
78
68
79
```shell
69
80
source~/.zshrc
@@ -73,27 +84,38 @@ source ~/.bash_profile
73
84
74
85
## Usage
75
86
76
-
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`).
87
+
1. Test the script by running the following command from a Git repository directory with a Jira ticket branch (Example - `TEST-1234-Your-GitHub-Branch`).
77
88
78
89
```shell
79
90
cm
91
+
# OR #
92
+
./git-commit-push-script.sh
80
93
```
81
94
82
-
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.
95
+
2. The script will stage, request the commit message from Ollama and Mistral with the `git diff`, commit with the ticket prefix and message, and push the changes to the remote branch.
83
96
84
97
```shell
85
-
[TEST-1234 f94df31] TEST-1234 Fix: Remove unnecessary text from Gemini prompt
86
-
1 file changed, 1 insertion(+), 1 deletion(-)
87
-
Branch 'TEST-1234' exists on remote. Pushing changes.
0 commit comments