diff --git a/commands/gacp/README.md b/commands/gacp/README.md new file mode 100644 index 0000000..f75cde2 --- /dev/null +++ b/commands/gacp/README.md @@ -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
+ +Runs git add ., git commit -m "message", and git push origin main in a single command.
+ +2) Error Handling
+ +Checks if the user has provided a commit message and warns if it’s missing.
+ +3) Optional Branch Handling
+ +By default, pushes to the main branch, but the branch can be customized in future versions.
\ No newline at end of file diff --git a/commands/gacp/gacp.sh b/commands/gacp/gacp.sh new file mode 100644 index 0000000..791a4f3 --- /dev/null +++ b/commands/gacp/gacp.sh @@ -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 +}