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

Dipsan Kadariya @dipsankadariya

About: 21 | Software Developer | Writer | Cybersecurity Enthusiast | Learner

Location:
Birtamode-Jhapa
Joined:
Aug 29, 2024

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

Publish Date: Aug 29 '24
3 2

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

Comments 2 total

  • King Triton
    King TritonAug 29, 2024

    This is fantastic! I've been looking for a way to streamline my Git workflow, and this script seems like it will save me a lot of time. The step-by-step setup instructions are also very clear and easy to follow. I especially appreciate the flexibility to customize the commit message. Can't wait to give this a try in my next project! Thank you for sharing!

    • Dipsan Kadariya
      Dipsan KadariyaAug 29, 2024

      Thank you so much for you feedback. Its my pleasure to be able to help.
      This script is designed to work globally across any project on your system. so once you have made the configuration, you can use it any project without any additional steps.

Add comment