- Home
- Skills
- DevOps & Cloud
- Push to GitHub When Git Push Fails
More screenshots
Works with the AI Agents you already use
Push to GitHub When Git Push Fails
When git push can't sign in but you have a GitHub token, this pushes your commits through GitHub's API instead.
$9
Push to GitHub When Git Push Fails
Example session with this skill installed
The git credential helper is broken on this server. I have a GITHUB_TOKEN. Push my current local HEAD on 'main' to 'origin/main' for the repo owner/webapp using the REST API.
- Read your context and instructions
- Compiled the push to github
I have successfully pushed the local tree to GitHub using the Git Database API. The remote head was reconciled via tree matching, and a new commit has been created and linked.
GitHub REST API Push Log
| Step | Action | Status | Details |
|---|---|---|---|
| 1 | GET Reference | Success | Remote SHA: a1b2c3d... |
| 2 | Ancestry Check | Success | Fast-forward verified via merge-base |
| 3 | Diff Calculation | Success | 3 files changed (2 modified, 1 added) |
| 4 | POST Blobs | Success | Created 3 blobs for changed content |
| 5 | POST Tree | Success | New Tree SHA: f6g7h8i... |
| 6 | POST Commit | Success | Commit SHA: z9y8x7w... |
| 7 | PATCH Ref | Success | refs/heads/main updated to z9y8x7w |
# Verification of final state
# GET /repos/owner/webapp/git/refs/heads/main
{
"ref": "refs/heads/main",
"object": {
"sha": "z9y8x7w...",
"type": "commit",
"url": "https://api.github.com/repos/owner/webapp/git/commits/z9y8x7w..."
}
}
Next steps
- Run
git fetch originlocally to sync your local tracking branch with the new remote SHA. - Verify the commit appears in the GitHub UI under the
mainbranch. - Clear the
GITHUB_TOKENfrom your environment if it is no longer needed.
Connects securely to your tools. The creator never sees your data.
About this skill
Sometimes git itself can't push: no credential helper on the machine, a sandbox with only web access, an auth setup that would take longer to fix than the push is worth. If you have a GitHub API token, the same commits can be assembled through GitHub's API directly — upload the changed files, build the tree, create the commit, move the branch.
Inside the package: the skill file with the full sequence and its preconditions, a small working Python implementation, and a table of the API calls in order. The edge cases are the valuable part, because they cost real debugging time: an empty repository refuses API pushes with a 409 until you seed it with one file through a different endpoint, and pushing a tree that's already identical to the remote fails with a 422 unless you check for that case first.
A run goes like this: your repo must be committed and clean, and the remote must be behind you or matchable by tree — this method never force-pushes. The agent reads the remote branch, stops and reports "already up to date" if the remote head matches yours, uploads only the changed files with their correct file modes, builds the new commit on top of the remote head, and verifies the branch actually moved. The token comes from an environment variable and is never written into a file or a log.
Fast-forward only; no force-pushes. Inefficient for commits with 1000+ files due to API rate limits. Not for large binaries exceeding API blob limits. Requires a clean working tree.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 6 days ago
Requires
Permissions
Allowed Hosts