-
Open a terminal.
-
Run this to create the script file:
nano push
-
Paste the following content:
#!/bin/bash # Check if a commit message is provided if [ $# -eq 0 ]; then echo "β Usage: push \"your commit message\"" exit 1 fi # Combine all arguments into one commit message commit_message="$*" echo "π Staging changes..." git add . echo "π Committing changes..." git commit -m "$commit_message" echo "π Pushing to remote..." git push echo "β Done!"
-
Save and exit:
- Press
CTRL+O, thenENTERto save. - Press
CTRL+Xto exit.
- Press
Run:
chmod +x pushmkdir -p ~/.local/binmv push ~/.local/bin/echo $PATHIf not, do the following based on your shell:
echo $SHELLecho 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrcecho 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrcGo to any Git-tracked folder and run:
push "your commit message here"You should see:
π Staging changes...
π Committing changes...
π Pushing to remote...
β
Done!
letβs enhance your workflow by:
- β
Creating a script that also shows
git statusafter push - β
Creating a global alias named
pushso you donβt have to move or chmod anything manually.
Open your shell config file:
-
For Bash:
nano ~/.bashrc -
For Zsh:
nano ~/.zshrc
Paste this at the bottom of the file:
function push() {
if [ $# -eq 0 ]; then
echo "β Usage: push \"your commit message\""
return 1
fi
local commit_message="$*"
echo "π Staging changes..."
git add .
echo "π Committing..."
git commit -m "$commit_message"
echo "π Pushing to remote..."
git push
echo "π Status:"
git status
echo "β
Done!"
}source ~/.bashrc # or ~/.zshrcFrom any Git project directory:
push "updating README with new section"- β
Adds all changes:
git add . - β Commits with your message
- β Pushes to the current branch
- β
Displays
git statusto confirm whatβs left (if anything)