git-push-to-main

Commits current changes on the default branch and pushes them to the remote in one uninterrupted run.

Updated Dec 18, 2025
One-click install
npx skills add https://github.com/l0lxl0lw/dotfiles --skill git-push-to-main-l0lxl0lw
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-push-to-main
Source: https://github.com/l0lxl0lw/dotfiles/tree/main/ai/shared/skills/git/git-push-to-main
Command: npx skills add https://github.com/l0lxl0lw/dotfiles --skill git-push-to-main-l0lxl0lw

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve? Shipping verified work to the default branch normally involves a chain of manual git steps — checking remote state, staging, writing a commit message, pushing — with easy mistakes like pushing without pulling or force-pushing over someone else's commit. This Skill runs the whole sequence autonomously and safely. ## Core Features & Use Cases - One-shot commit and push: Analyzes repository state, writes the commit message itself, stages files, commits, and pushes without stopping for confirmation. - Remote divergence handling: Fetches origin first, detects when the local branch is behind, and integrates with git pull --ff-only or --rebase before pushing. - Safety guardrails: Refuses to run on feature branches, blocks sensitive files (.env, .pem, .key) from staging, rejects AI attribution in commit messages, and requires explicit confirmation before any force-push. - Use Case: After finishing and verifying a small fix on main, invoke the skill and it commits the change with an appropriate message and pushes it to origin in a single turn. ## Quick Start Tell the agent to push this to main, and it will analyze the repo, commit the current changes, and push them to the remote default branch.

Frequently Asked Questions about git-push-to-main

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I commit and push changes directly to main in one step?

Invoke the skill on the default branch and it analyzes the repository, writes a commit message, stages files, commits, and pushes in a single turn. It pulls with --ff-only or --rebase first if the remote has moved ahead.

What happens if the remote main branch has new commits?

The analysis script fetches origin and reports if you are behind. The skill then runs git pull --ff-only, or git pull --rebase if you have local commits, before pushing. Rebase conflicts are resolved together with the user.

Can I use this on a feature branch instead of main?

No. The skill stops immediately if the current branch is not the default branch (main or master). For feature branches, use the related git-push-branch skill, or git-branch-and-pr if the work needs a pull request.

Does it ever force-push to the remote?

Only when an explicitly requested amend rewrote an already-pushed commit, and only after asking the user via a confirmation prompt. It always uses --force-with-lease, never plain --force, and never force-pushes past a rejected push.

Why were some of my files not committed?

The staging script deliberately skips sensitive files matching patterns like .env, .pem, .key, .secret, .credentials, and .token. The skipped files are listed in the final report and can be staged manually if intended.