Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Custom-Command #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions commands/gacp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# gacp

## Description
The gacp command simplifies the process of adding, committing, and pushing changes to a Git repository. It automates the three most common commands developers use:

git add .
git commit -m "message"
git push origin main
This saves time by avoiding repetitive manual inputs, especially for frequent commits.

## Syntax
```bash
gacp "commit message"
```

## Features of the Custom Command
1) Simple Workflow Automation </br>

Runs git add ., git commit -m "message", and git push origin main in a single command.</br>

2) Error Handling</br>

Checks if the user has provided a commit message and warns if it’s missing.</br>

3) Optional Branch Handling</br>

By default, pushes to the main branch, but the branch can be customized in future versions.</br>
22 changes: 22 additions & 0 deletions commands/gacp/gacp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
gacp() {
if [ -z "$1" ]; then
echo "Error: Commit message is required."
echo "Usage: gacp \"commit message\""
return 1
fi

echo "Adding changes..."
git add .

echo "Committing with message: $1"
git commit -m "$1"

echo "Pushing to origin main..."
git push origin main

if [ $? -eq 0 ]; then
echo "Changes successfully pushed to 'main' branch."
else
echo "Error: Failed to push changes."
fi
}