Skip to content

Commit 332a3b9

Browse files
authored
Merged to main
2 parents 679585b + 7c493c8 commit 332a3b9

File tree

1 file changed

+49
-23
lines changed

1 file changed

+49
-23
lines changed

README.md

Lines changed: 49 additions & 23 deletions
Original file line numberDiff line numberDiff 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 👨🏻‍💻➡️
22

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.
44

55
## Table of Contents
66

@@ -16,8 +16,10 @@ Staging, committing, and pushing code is a repetative manual process. Writing de
1616
| -------------------------------- | -------------------------------------------------------------------------------------------------- |
1717
| Git Staging | Staging any modified files for commit using `git add -A`. |
1818
| 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`. |
2020
| 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`. |
2123
| Git Push | Pushing local commits to remote branch with `git push`. |
2224
| Git Push Retry (Pull & Push) | If a push fails, the script will `git pull` from the remote branch and push again. |
2325

@@ -27,8 +29,11 @@ Staging, committing, and pushing code is a repetative manual process. Writing de
2729
| ------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- |
2830
| Terminal or Shell | A terminal or shell for configuring and running the script. | [Download Terminal](https://www.apple.com/macos/terminal/) |
2931
| `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) |
3237

3338
## Installation
3439

@@ -56,14 +61,20 @@ chmod +x git-commit-push-script.sh
5661
alias cm='bash /path/to/git-commit-push-script/git-commit-push-script.sh'
5762
```
5863

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:
6065

6166
```shell
62-
export GEMINI_API_KEY=<your-gemini-api-key>
67+
homebrew install ollama
68+
# AND/OR #
69+
ollama serve
6370
```
71+
6. Download the Mistral AI model by running the following command:
6472

73+
```shell
74+
ollama pull mistral
75+
```
6576

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:
6778

6879
```shell
6980
source ~/.zshrc
@@ -73,27 +84,38 @@ source ~/.bash_profile
7384

7485
## Usage
7586

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`).
7788

7889
```shell
7990
cm
91+
# OR #
92+
./git-commit-push-script.sh
8093
```
8194

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.
8396

8497
```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.
88-
Enumerating objects: 5, done.
89-
Counting objects: 100% (5/5), done.
90-
Delta compression using up to 16 threads
91-
Compressing objects: 100% (3/3), done.
92-
Writing objects: 100% (3/3), 633 bytes | 633.00 KiB/s, done.
93-
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0 (from 0)
94-
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
95-
To https://github.com/wesleyscholl/git-commit-push-script.git
96-
ead30af..f94df31 TEST-1234 -> TEST-1234
98+
argo-gr-cr-test git:(WXYZ-1234) cm
99+
Removed sync options, enabled cron workflow
100+
spawn git commit -S -m WXYZ-1234 Removed sync options, enabled cron workflow
101+
Enter passphrase for "/Users/wscholl/.ssh/id_ed25519":
102+
[WXYZ-1234 94f179e] WXYZ-1234 Removed sync options, enabled cron workflow
103+
1 file changed, 7 deletions(-)
104+
Branch 'WXYZ-1234' exists on remote.
105+
Pulling latest changes from remote branch...
106+
From https://github.com/myOrg/argo-gr-cr-test
107+
* branch WXYZ-1234 -> FETCH_HEAD
108+
Already up to date.
109+
Pushing changes to remote WXYZ-1234 branch...
110+
Enumerating objects: 9, done.
111+
Counting objects: 100% (9/9), done.
112+
Delta compression using up to 8 threads
113+
Compressing objects: 100% (5/5), done.
114+
Writing objects: 100% (5/5), 671 bytes | 671.00 KiB/s, done.
115+
Total 5 (delta 4), reused 0 (delta 0), pack-reused 0 (from 0)
116+
remote: Resolving deltas: 100% (4/4), completed with 4 local objects.
117+
To https://github.com/myOrg/argo-gr-cr-test.git
118+
f546666..94f179e WXYZ-1234 -> WXYZ-1234
97119
```
98120

99121
## Troubleshooting
@@ -110,9 +132,13 @@ To resolve this error, remove the `-S` from the command in the `git-commit-push-
110132
git commit -m "<commit message>"
111133
```
112134

113-
If you want to use the -S flag, configure your Git configuration to use the GPG key for signing commits.
135+
Or if you want to use the -S flag, configure your Git configuration to use the GPG key for signing commits.
114136
Use the guide here: <https://docs.github.com/en/authentication/managing-commit-signature-verification/telling-git-about-your-signing-key>
115137

138+
## Contributing
139+
140+
Contributions are welcome! If you have suggestions for improvements or new features, please open an issue or submit a pull request.
141+
116142
## License
117143

118144
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

0 commit comments

Comments
 (0)