Skip to content

Instantly share code, notes, and snippets.

@lorens247
Last active July 31, 2024 17:40
Show Gist options
  • Save lorens247/d5fc9b95a764b3017a198558bd3ae4ea to your computer and use it in GitHub Desktop.
Save lorens247/d5fc9b95a764b3017a198558bd3ae4ea to your computer and use it in GitHub Desktop.
git-commit-push
A simple script to streamline the process of adding changes, committing them with a message and pushing to your Git repository.
Here's a basic script in Bash that accomplishes this:
### Bash Script
1. Create a new file named `git-commit-push.sh`.
2. Add the following content to the file:
```
# Check if a commit message was provided
if [ -z "$1" ]
then
echo "Commit message is required"
exit 1
fi
# Stage all changes
git add .
# Commit with the provided message
git commit -m "$1"
# Push to the current branch
git push
# Print a success message
echo "Changes have been pushed successfully."
```
3. Save the file and make it executable:
```bash
chmod +x git-commit-push.sh
```
### Usage
To use the script, navigate to your Git repository's directory in the terminal and run:
```
./git-commit-push.sh "Your commit message here"
```
Replace `"Your commit message here"` with your actual commit message. The script will automatically add all changes, commit them with the provided message, and push to the remote repository.
@lorens247
Copy link
Author

Gist made public for easy sharing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment