Automate Git Commands using shell Script (Easy)
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.ps
1
script:
1. Create the Script
In a text editor, create a new file and save it as
git-automation.ps
1
(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:
git-automation.ps1 "commit-message"