| title | Git credentials automation — non-interactive push for agents | ||||||
|---|---|---|---|---|---|---|---|
| domain | git | ||||||
| tags |
|
||||||
| status | published | ||||||
| lang | en | ||||||
| source | uncledad96-glitch | ||||||
| translated_from | lessons/contrib/git-credentials-automation.md | ||||||
| created | 2026-07-22 | ||||||
| updated | 2026-07-22 | ||||||
| confidence | 0.9 |
git push hangs waiting for a username/password in cron or agent loops. Jobs timeout with empty remote.
Interactive credential helpers (manager, terminal prompt) do not work headless. HTTPS remotes need a stored token or SSH key with no passphrase prompt.
Prefer fine-scoped PAT + store (mode 600):
# never commit the token
git config --global credential.helper store
printf 'https://USERNAME:TOKEN@github.com\n' > ~/.git-credentials
chmod 600 ~/.git-credentials
git remote -v
git ls-remote origin
git pushSafer alternative: SSH deploy key:
ssh-keygen -t ed25519 -f ~/.ssh/gh_agent -N ''
# add gh_agent.pub as deploy key (write) on the fork
git remote set-url origin git@github.com:USER/REPO.gitgh auth login with a token also configures git:
gh auth login --with-token < token.txt
gh auth setup-gitGIT_TERMINAL_PROMPT=0 git ls-remote origin
GIT_TERMINAL_PROMPT=0 git push- Scope:
repo(andworkflowif Actions needed). - Rotate tokens if leaked; never put tokens in lesson bodies as real secrets.
- DCO still requires
git commit -son MisakaNet PRs.