Automate Git Commands with Shell Scripts 🚀 | Boost Your Workflow 📜

dipsankadariya

Dipsan Kadariya

Posted on August 29, 2024

Automate Git Commands with Shell Scripts 🚀 | Boost Your Workflow 📜

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

  1. In a text editor, create a new file and save it as git-automation.ps1 (or any preferred name).
  2. 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

  1. Open PowerShell and run:

    mkdir C:\Scripts
    
  2. Move your script to this directory:

    move C:\Users\dipsa\Desktop\git-automation.ps1 C:\Scripts\
    

3. Add the Directory to PATH

  1. Click "Environment Variables."
  2. In "System variables," select Path and click "Edit."
  3. Click "New" and add:

    C:\Scripts
    
  4. Click "OK" to save and close the dialog boxes.

4. Set Execution Policy

  1. Open PowerShell and run:

    Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
    
  2. 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"
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
dipsankadariya
Dipsan Kadariya

Posted on August 29, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related