Skip to content

Instantly share code, notes, and snippets.

@AbiruzzamanMolla
Created August 25, 2024 13:26
Show Gist options
  • Save AbiruzzamanMolla/c7af39e0997d9713f59410d4edd22627 to your computer and use it in GitHub Desktop.
Save AbiruzzamanMolla/c7af39e0997d9713f59410d4edd22627 to your computer and use it in GitHub Desktop.
my gitbash alias
# Define the gitupdate function
gitupdate() {
local commitMessage="$1"
local branch="$2"
if [ -z "$commitMessage" ]; then
echo "Error: Commit message is required."
return 1
fi
echo -e "\nExecuting gitupdate command with the following actions:"
echo " - Staging all changes in the repository."
echo " - Committing changes with message '$commitMessage'."
if [ -n "$branch" ]; then
echo " - Pushing changes to branch '$branch'."
else
echo " - Pushing changes to the current branch."
fi
# Display current repository status
echo -e "\n\nCurrent Git status:"
git status
# Stage all changes
echo -e "\n\nStaging all changes..."
sleep 0.5
echo -n "Adding files to staging area:"
spinner='-\|/'
for i in {1..10}; do
echo -n "${spinner:i%${#spinner}:1}"
sleep 0.1
echo -en "\b"
done
git add .
echo -e "\nFiles added to staging area successfully."
# Commit with the provided message
echo -e "\n\nCommitting changes with message '$commitMessage'..."
sleep 0.5
echo -n "Committing changes:"
for i in {1..10}; do
echo -n "${spinner:i%${#spinner}:1}"
sleep 0.1
echo -en "\b"
done
git commit -m "$commitMessage"
echo -e "\nChanges committed successfully."
# Push changes
if [ -n "$branch" ]; then
echo -e "\n\nPushing changes to branch '$branch'..."
else
echo -e "\n\nPushing changes to current branch..."
fi
sleep 0.5
echo -n "Pushing changes:"
for i in {1..10}; do
echo -n "${spinner:i%${#spinner}:1}"
sleep 0.1
echo -en "\b"
done
if [ -n "$branch" ]; then
git push origin "$branch"
else
git push
fi
echo -e "\nChanges pushed successfully."
# Display updated repository status
echo -e "\n\nUpdated Git status:"
git status
}
# Alias for the function
alias gitupdate=gitupdate
alias pa='php artisan'
@AbiruzzamanMolla
Copy link
Author

Example Commands
pa optimize
pa serve
gitupdate "your commit message"

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