|
1 | | -# git-commit-push-script |
| 1 | +# git-commit-push-script - Automating Staging, Committing and Pushing to GitHub 👨🏻💻➡️ |
| 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. |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | +* [What this script automates](#what-this-script-automates) |
| 7 | +* [User input required](#user-input-required) |
| 8 | +* [Requirements](#requirements) |
| 9 | +* [Installation](#installation) |
| 10 | +* [Usage](#usage) |
| 11 | +* [License](#license) |
| 12 | + |
| 13 | +## What this script automates: |
| 14 | + |
| 15 | +| Name | Description | |
| 16 | +| --- | --- | |
| 17 | +| Git Staging | Staging any modified files for commit using `git add -A`. | |
| 18 | +| Git Commit Message | Copying the ticket number of the Jira ticket as the commit message prefix. Example: `[CRS-12345]`. | |
| 19 | +| Git Commit | Committing staged files with the commit message using `git commit -S -m "<commit message>"`. | |
| 20 | +| Git Push | Pushing local commits to remote branch with `git push`. | |
| 21 | + |
| 22 | +## User input required: |
| 23 | + |
| 24 | +| Name | Description | |
| 25 | +| --- | --- | |
| 26 | +| Alias Command | The alias command to be used for the script: `cm`. | |
| 27 | +| Commit Message | The commit message with description of the changes made. | |
| 28 | + |
| 29 | +## Requirements |
| 30 | + |
| 31 | +| Name | Description | Link, Location, or Command | |
| 32 | +| --- | --- | --- | |
| 33 | +| Terminal or Shell | A terminal or shell for configuring and running the script. | [Download Terminal](https://www.apple.com/macos/terminal/) | |
| 34 | +| `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/) | |
| 35 | + |
| 36 | + |
| 37 | +## Installation |
| 38 | + |
| 39 | +1. Clone the git-commit-push-script repository to your local computer. |
| 40 | + |
| 41 | +```shell |
| 42 | +git clone https://github.com/wesleyscholl/git-commit-push-script.git |
| 43 | +``` |
| 44 | + |
| 45 | +2. Navigate to the git-commit-push-script directory with your terminal, shell, command line, or bash. |
| 46 | + |
| 47 | +```shell |
| 48 | +cd git-commit-push-script |
| 49 | +``` |
| 50 | + |
| 51 | +3. Make the script executable by running the following command: |
| 52 | +```shell |
| 53 | +chmod +x git-commit-push-script.sh |
| 54 | +``` |
| 55 | + |
| 56 | +4. Configure the alias command for the script in zshrc or bash_profile. |
| 57 | +```shell |
| 58 | +alias cm='bash /path/to/git-commit-push-script/git-commit-push-script.sh' |
| 59 | +``` |
| 60 | + |
| 61 | +5. Reload the terminal or shell configuration by running the following command: |
| 62 | +```shell |
| 63 | +source ~/.zshrc |
| 64 | +# OR # |
| 65 | +source ~/.bash_profile |
| 66 | +``` |
| 67 | + |
| 68 | +## Usage |
| 69 | + |
| 70 | +6. Test the script by running the following command from a Git repository directory with a Jira ticket branch. |
| 71 | + |
| 72 | +```shell |
| 73 | +cm |
| 74 | +``` |
| 75 | + |
| 76 | +7. Enter your commit message when prompted. |
| 77 | +```shell |
| 78 | +Enter commit message: |
| 79 | +``` |
| 80 | + |
| 81 | +8. The script will stage, commit with the ticket prefix, and push the changes to the remote branch. |
| 82 | +```shell |
| 83 | +Enter commit message: Test message |
| 84 | +Commit message: CRS-12345 - Test message |
| 85 | +[CRS-12345-Git-Script-Test be6fe58] CRS-12345 - Test message |
| 86 | + 1 file changed, 2 insertions(+), 1 deletion(-) |
| 87 | +Enumerating objects: 5, done. |
| 88 | +Counting objects: 100% (5/5), done. |
| 89 | +Delta compression using up to 16 threads |
| 90 | +Compressing objects: 100% (3/3), done. |
| 91 | +Writing objects: 100% (3/3), 643 bytes | 643.00 KiB/s, done. |
| 92 | +Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 |
| 93 | +To https://github.com/wesleyscholl/git-commit-push-script.git |
| 94 | + c76b73c..be6fe58 CRS-12345-Git-Script-Test -> CRS-12345-Git-Script-Test |
| 95 | +``` |
| 96 | + |
| 97 | +9. Enjoy the script! |
| 98 | + |
| 99 | +## License |
| 100 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
| 101 | + |
0 commit comments