惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Vercel News
Vercel News
B
Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
GbyAI
GbyAI
IT之家
IT之家
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
博客园_首页
C
Check Point Blog
博客园 - 【当耐特】
美团技术团队
Last Week in AI
Last Week in AI
A
About on SuperTechFans
雷峰网
雷峰网
MongoDB | Blog
MongoDB | Blog
Microsoft Azure Blog
Microsoft Azure Blog
M
MIT News - Artificial intelligence
Martin Fowler
Martin Fowler
J
Java Code Geeks
B
Blog RSS Feed
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
G
Google Developers Blog
F
Fortinet All Blogs

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
1Password, GitHub, and Git CLI with Multiple Users
Sean Boult · 2026-05-02 · via DEV Community

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.

This means I want to be able to run gh commands as the correct user, as well as have git commands pick the correct SSH key.

If you want to have a single dotfiles repo for both work and personal development, this should give you something to follow.

⚠️ If you use a single GitHub account for everything, this article might not be very helpful for you.

Prerequisites

Tools you’ll need to make all this work:

You’ll also want to designate some folders to hold projects. This guide will use the following structure:

  • ~/code - where I do personal development on my personal machine
  • ~/oss - where I do all my work open source code (repros, demos, etc.)

1) Set a global default (personal)

In ~/.gitconfig:

[user]
    name = Sean Boult
    email = 996134+Hacksore@users.noreply.github.com

[includeIf "gitdir:~/oss/"]
    path = ~/.gitconfig-work

Enter fullscreen mode Exit fullscreen mode

So we’ve added the default user in the [user] block and added an includeIf (docs) block that specifies that inside ~/oss we’ll make sure to load the config options in ~/.gitconfig-work.

Given that you need to be “inside a git directory” based on the gitdir clause, it means that ~/oss should be a valid Git directory.

To do that, run this in ~/oss:

# make ~/oss a valid git repo
git init

Enter fullscreen mode Exit fullscreen mode

We will also want to create a .gitignore file to not track anything in this directory.

# ~/oss/.gitignore
# Sentinel repo: exists only so includeIf matches when cwd is ~/oss
# Ignore all subdirs (they're separate repos)
*

Enter fullscreen mode Exit fullscreen mode

2) Put work identity in a separate config

Create ~/.gitconfig-work:

[user]
    name = Sean Boult
    email = <yourWorkEmail> # replace this with your email
    # optional ssh key signing
    # signingkey = ~/.ssh/id_rsa.pub

Enter fullscreen mode Exit fullscreen mode

3) Make SSH key selection automatic

Now configure SSH so Git will pick the right key based on the repo you are in.

In ~/.ssh/config:

# Github and we default personal
Host github.com
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_rsa.personal
    IdentitiesOnly yes

Enter fullscreen mode Exit fullscreen mode

Then, in ~/.gitconfig-work, add:

[core]
    sshCommand = ssh -i ~/.ssh/id_rsa -o IdentitiesOnly=yes

Enter fullscreen mode Exit fullscreen mode

At this point:

  • Any repo elsewhere uses your personal Git identity and personal SSH key.
  • Any repo under ~/oss uses your work Git identity and work SSH key.

1Password CLI Plugin

The next step is to allow the gh CLI to know what directory you’re in and use the right GitHub PAT (personal access token).

To put it simply, I have two PATs in my 1Password vault: gh-pat-cli (personal) and gh-pat-cli-sboult (work/oss). In the op setup, instruct 1Password to use the gh-pat-cli-sboult PAT so that when you’re in ~/oss, it uses the correct PAT to authenticate with the GitHub CLI.

Use 1Password to securely authenticate the GitHub CLI is a helpful doc if you get stuck.

Work repos (~/oss)

Example:

cd ~/oss

git clone git@github.com:awslabs/mcp.git
# or
# gh repo clone awslabs/mcp

Enter fullscreen mode Exit fullscreen mode

Once the repo is under ~/oss/, Git uses:

  • your work user.name / user.email
  • your work SSH key

Then normal commands work:

git remote -v
git push

gh pr list

Enter fullscreen mode Exit fullscreen mode

Personal repos

Outside of ~/oss, everything uses your default (personal) identity.

Example:

git clone git@github.com:Hacksore/test.git
# or
# gh repo clone test

Enter fullscreen mode Exit fullscreen mode


That’s it! You should now be able to reproduce the setup I have.

Happy coding 😊!