configure-git-cli

Configure Git CLI with GitHub authentication using environment variables (GITHUB_EMAIL, GITHUB_NAME, GITHUB_PAT)

⭐35stars🔀3forks📁View on GitHub🕐Updated Jan 5, 2026⬇️2downloads

When & Why to Use This Skill

This Claude skill automates the configuration of the Git CLI for GitHub authentication using environment variables. It streamlines the setup of global user identity and credential storage (GITHUB_PAT), enabling AI agents and automated scripts to perform seamless git operations like cloning, committing, and pushing without manual login prompts.

Use Cases

  • Automated Agentic Workflows: Enabling AI agents to perform end-to-end coding tasks, such as fixing bugs and submitting Pull Requests, by pre-configuring necessary repository permissions.
  • CI/CD Pipeline Initialization: Setting up Git credentials within headless environments or containers to allow automated scripts to push code changes or tags to GitHub.
  • Headless Server Configuration: Quickly preparing remote servers or development environments for Git operations where interactive authentication is not feasible.
  • Standardized Environment Setup: Ensuring consistent Git identity and authentication across different development stages using environment-based configuration.
nameconfigure-git-cli
descriptionConfigure Git CLI with GitHub authentication using environment variables (GITHUB_EMAIL, GITHUB_NAME, GITHUB_PAT)
compatibilityRequires git installed and GITHUB_EMAIL, GITHUB_NAME, GITHUB_PAT environment variables set
licenseMIT

Configure Git CLI

When to use this skill

Use this skill before performing git operations (clone, push, commit, etc.). Required by the codebase-fix-and-pr skill.

Prerequisites

Required environment variables:

  • GITHUB_EMAIL: Email address for git commits
  • GITHUB_NAME: Name for git commits
  • GITHUB_PAT: GitHub Personal Access Token with repo and workflow scopes

Workflow

Step 1: Verify Git Installation

git --version

Step 2: Configure Git User Identity

git config --global user.email "${GITHUB_EMAIL}"
git config --global user.name "${GITHUB_NAME}"

Step 3: Configure Credentials

Enable credential storage and preload GitHub credentials:

git config --global credential.helper store
cat <<EOF > ~/.git-credentials
https://${GITHUB_NAME}:${GITHUB_PAT}@github.com
EOF
chmod 600 ~/.git-credentials

Step 4: Verify Configuration

git config user.email
git config user.name
git ls-remote https://github.com/test/test.git

All commands should succeed without prompting for credentials.

Success Criteria

  • ✅ git --version succeeds
  • ✅ git config user.email and git config user.name return correct values
  • ✅ git ls-remote succeeds without prompting

Troubleshooting

Issue Solution
Git not found Install git using your system package manager
Authentication failed Verify GITHUB_PAT is valid, not expired, and has repo scope
Permission denied Check write permissions to home directory
Credentials not working Run rm ~/.git-credentials and reconfigure