Automate Git Commands with Shell Scripts 🚀 | Boost Your Workflow 📜
Dipsan Kadariya
Posted on August 29, 2024
Git Automation Script
Overview
This repository contains a PowerShell script designed to automate common Git operations.This script is designed to work globally across any project on your system.Once configured, the script simplifies the process of staging changes, committing with a message, and pushing updates to a remote repository.
Features
- Automate Git Operations: Add all changes, commit with a message, and push to the remote repository with a single command.
- Easy to Use: Run the script with a custom commit message to handle the Git workflow.
Setup Instructions
Follow these steps to set up and use the git-automation.ps1
script:
1. Create the Script
- In a text editor, create a new file and save it as
git-automation.ps1
(or any preferred name). -
Add the following content to the file:
if ($args.Length -eq 0) { $COMMIT_MSG = "Auto-commit" } else { $COMMIT_MSG = $args[0] } git add . git commit -m $COMMIT_MSG git push
2. Create a Directory for the Script
-
Open PowerShell and run:
mkdir C:\Scripts
-
Move your script to this directory:
move C:\Users\dipsa\Desktop\git-automation.ps1 C:\Scripts\
3. Add the Directory to PATH
- Click "Environment Variables."
- In "System variables," select
Path
and click "Edit." -
Click "New" and add:
C:\Scripts
Click "OK" to save and close the dialog boxes.
4. Set Execution Policy
-
Open PowerShell and run:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Confirm by typing
Y
if prompted.
Usage
To use the script, run the following command from any project directory:
powershell
git-automation.ps1 "commit-message"
Posted on August 29, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.