agentleFS
IvanLi-CNIvanLi-CN/agent-toolkit/skills/git-remote-troubleshoot/SKILL.md

git-remote-troubleshoot

Skill0 starsChanged 17 days agoMITView on GitHub

Diagnose Git remote and auth issues.

  • Reads credentials
  • Commits and pushes

The file

Show its rules and text

We split this skill into the rules it gives an agent

20 rules. About 0 are common, 9 are distinctive, and 11 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈9

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 11

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Never “work around” SSH failures by pushing via an explicit HTTPS URL (forbidden): git push -u https://github.com/<owner>/<repo>.git …

    line 16
  2. Very specific:

    Never use git push <url> <branch> (URL-typed remote) as a workaround.

    line 17
  3. Very specific:

    Do not rewrite origin (or any remote) to HTTPS as a workaround unless the user explicitly requests HTTPS.

    line 18
  4. Very specific:

    Prefer read-only connectivity checks first: git ls-remote <remote>.

    line 19
  5. Distinctive:

    Do not run git push unless the user explicitly asks you to push.

    line 20
  6. Very specific:

    Do not modify global configs (~/.ssh/config, ~/.gitconfig, credential helpers) without asking first.

    line 21
  7. Distinctive:

    Ask for (or run) these and capture the *full* error text:

    line 25
  8. Very specific:

    SSH: if remote looks like git@host:owner/repo.git or ssh://...

    line 39
  9. Very specific:

    HTTPS: if remote looks like https://host/owner/repo.git

    line 40
  10. Distinctive:

    If the remote is GitHub and port 22 is blocked, test GitHub’s supported SSH-over-443 endpoint:

    line 65
  11. Very specific:

    If port 443 works, apply GitHub’s official fix by adding this to ~/.ssh/config (ask before editing):

    line 71
  12. Distinctive:

    If you need deeper SSH debug logs (still read-only), use:

    line 97
  13. Distinctive:

    Ensure the correct public key is uploaded to the Git hosting account.

    line 115
  14. Very specific:

    If multiple keys exist, pin the right key for the host in ~/.ssh/config:

    line 116
  15. Very specific:

    Do not blindly delete known_hosts.

    line 126
  16. Very specific:

    If you must remove an entry, remove only the matching host line (or use ssh-keygen -R <host> with explicit user approval).

    line 130
  17. Distinctive:

    If GitHub is involved and auth fails, you generally need a PAT (password auth is not supported) or you should switch to SSH (user decision).

    line 141
  18. Distinctive:

    If you need deeper HTTPS debug logs (read-only), use:

    line 143
  19. Distinctive:

    After applying a fix, verify with a read-only operation:

    line 151
  20. Distinctive:

    Only after the user explicitly asks to push, run the push using the configured remote name (not a raw HTTPS URL):

    line 157

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Git remote troubleshoot

Prerequisites and boundary

This is text-only guidance using installed Git and the existing SSH or HTTPS tools on Linux/macOS. It owns no production executable and requires no Bun/Python runtime for diagnosis. Start with git remote -v, git status -sb and the exact failing command/error; these identify the configured target and transport without changing local configuration. The result is a diagnosis, supporting read-only observations and a proposed minimal fix. Any config change or push follows the explicit authorization rules below.

Repository maintainers can run bun test ./tests/helper_sources.test.ts to exercise linked-source helper entrypoints and retained runtime boundaries. Bun is a developer/test prerequisite only for this text Skill; those smoke tests make no live connectivity or authentication claim.

Hard rules (strict)

  • Never “work around” SSH failures by pushing via an explicit HTTPS URL (forbidden): git push -u https://github.com/<owner>/<repo>.git <branch>
  • Never use git push <url> <branch> (URL-typed remote) as a workaround; always use a configured remote name (e.g., origin).
  • Do not rewrite origin (or any remote) to HTTPS as a workaround unless the user explicitly requests HTTPS.
  • Prefer read-only connectivity checks first: git ls-remote <remote>.
  • Do not run git push unless the user explicitly asks you to push.
  • Do not modify global configs (~/.ssh/config, ~/.gitconfig, credential helpers) without asking first; keep changes minimal and make a backup.

1) Collect minimal facts

Ask for (or run) these and capture the full error text:

git remote -v
git config --get remote.origin.url
git status -sb

Also collect:

  • The exact failing command (git clone/fetch/pull/push ...)
  • The network context (VPN? proxy? corporate network? captive portal?)

2) Classify: SSH vs HTTPS

  • SSH if remote looks like git@host:owner/repo.git or ssh://...
  • HTTPS if remote looks like https://host/owner/repo.git

Proceed based on the transport.

Quick signature map

  • Connection closed by <ip> port 22 / ssh: connect to host ... port 22: ... → network path/port blocked (often port 22)
  • Permission denied (publickey) → SSH key selection/authz problem
  • Host key verification failed → known_hosts mismatch / host key not trusted
  • Repository not found → wrong remote URL or missing access

3) SSH failures

A) Port 22 blocked / network path broken

Common indicators:

  • Mentions port 22, Connection timed out, Connection closed, No route to host
  • ssh -T git@github.com fails quickly or hangs then fails

Safe tests (no pushing):

ssh -T git@github.com

If the remote is GitHub and port 22 is blocked, test GitHub’s supported SSH-over-443 endpoint:

ssh -T -p 443 git@ssh.github.com

If port 443 works, apply GitHub’s official fix by adding this to ~/.ssh/config (ask before editing):

Host github.com
  HostName ssh.github.com
  Port 443
  User git

Then re-test:

ssh -T git@github.com
git ls-remote origin

Reference (official GitHub docs):

https://docs.github.com/en/authentication/troubleshooting-ssh/using-ssh-over-the-https-port

Notes:

  • The first connection after switching to port 443 may show a known_hosts warning; verify the host key against GitHub’s published fingerprints before accepting.
  • GitHub’s doc includes caveats for GitHub Enterprise Server and some Enterprise Cloud configurations (e.g., data residency).

If you need deeper SSH debug logs (still read-only), use:

GIT_SSH_COMMAND="ssh -vvv" git ls-remote origin

B) Permission denied (publickey)

This usually means SSH auth (key selection, agent, account access), not networking.

Checklist:

ssh -vT git@github.com
ssh-add -L

Common fixes:

  • Ensure the correct public key is uploaded to the Git hosting account.
  • If multiple keys exist, pin the right key for the host in ~/.ssh/config:
Host github.com
  IdentityFile ~/.ssh/id_ed25519
  IdentitiesOnly yes

C) Host key verification failed / host key mismatch

Do not blindly delete known_hosts.

Preferred approach:

  • Identify the specific offending entry, and validate the expected fingerprint from the provider docs.
  • If you must remove an entry, remove only the matching host line (or use ssh-keygen -R <host> with explicit user approval).

4) HTTPS failures (when the remote already uses HTTPS)

Typical indicators:

  • fatal: Authentication failed
  • HTTP 401/403
  • SSL certificate problem

Workflow:

  • First confirm basic reachability: curl -I https://<host>
  • If GitHub is involved and auth fails, you generally need a PAT (password auth is not supported) or you should switch to SSH (user decision).

If you need deeper HTTPS debug logs (read-only), use:

GIT_TRACE=1 GIT_CURL_VERBOSE=1 git ls-remote origin

5) Verification before any write

After applying a fix, verify with a read-only operation:

git ls-remote origin

Only after the user explicitly asks to push, run the push using the configured remote name (not a raw HTTPS URL):

git push -u origin <branch>

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.