1Password, GitHub, and Git CLI with Multiple Users
The article explains how to configure Git, GitHub CLI, and 1Password CLI to automatically use different user identities for personal and work projects based on directory location. It outlines steps to set up separate Git configurations and SSH keys for projects in designated folders like ~/code and ~/oss. The integration with 1Password allows secure, context-aware authentication using different personal access tokens.
- ▪The setup uses Git's includeIf directive to apply different configurations based on the project directory.
- ▪Separate SSH keys are configured for personal and work environments to ensure proper authentication with GitHub.
- ▪1Password CLI stores multiple GitHub personal access tokens, enabling automatic token selection based on the current directory.
- ▪The ~/oss directory is initialized as a Git repository solely to satisfy Git's includeIf condition for config loading.
- ▪This approach supports developers who maintain distinct personal and work identities across GitHub repositories.
Opening excerpt (first ~120 words) tap to expand
try { if(localStorage) { let currentUser = localStorage.getItem('current_user'); if (currentUser) { currentUser = JSON.parse(currentUser); if (currentUser.id === 828306) { document.getElementById('article-show-container').classList.add('current-user-is-article-author'); } } } } catch (e) { console.error(e); } Sean Boult Posted on May 1 1Password, GitHub, and Git CLI with Multiple Users #github #cli #1password #tooling Do you use the git, github, and 1password CLI? I do! I want to be able to act as different users in certain directories to support my personal projects (~/code) and my work projects (~/oss) automatically, because, you know, developers automate everything.
…
Excerpt limited to ~120 words for fair-use compliance. The full article is at DEV.to (Top).