Commit and Push
Commit changes on the current branch and push to the remote.
Steps
- •
Check branch (prevent direct pushes to main/master)
bashBRANCH=$(git branch --show-current) if [ "$BRANCH" = "main" ] || [ "$BRANCH" = "master" ]; then echo "Direct pushes to main/master are not allowed" exit 1 fi
- •
Stage changes
bashgit add -A
- •
Commit
bashgit commit -m "<prefix>: <summary (imperative, concise)>"
- •
Push
bashgit push -u origin "$BRANCH"
One-liner
bash
MSG="fix: remove unnecessary debug log output" \ BRANCH=$(git branch --show-current) && \ if [ "$BRANCH" = "main" ] || [ "$BRANCH" = "master" ]; then \ echo "Direct pushes to main/master not allowed"; exit 1; \ fi && \ git add -A && git commit -m "$MSG" && git push -u origin "$BRANCH"
Notes
- •Always review diffs with
git statusorgit diffbefore executing - •Use conventional commit prefixes: feat, fix, refactor, perf, test, docs, build, ci, chore, style, revert