Urgent.News

What's breaking now, across thousands of outlets.

Tech

Using Multiple GitHub Accounts: Automatically Select the Correct `gh` PAT Based on Repo Owner

When using multiple GitHub accounts, the process of selecting the correct Personal Access Token (PAT) for git push or git pull over HTTPS can be a bit cumbersome. Specifically, when dealing with repositories from multiple owners, such as: https://github.com/aont/foo.git https://github.com/another-user/bar.git Git Credential Manager or gh auth git-credential might default to the currently active…

Managing multiple GitHub accounts can be challenging, especially when it comes to selecting the correct Personal Access Token (PAT) for different repositories. When working with repositories from various owners, such as GitHub and another-user, Git Credential Manager or gh auth git-credential may default to the currently active account, resulting in errors like "Permission denied." To overcome this issue, GitHub CLI (gh) provides a solution that automatically selects the appropriate PAT based on the repository owner.

The core of this solution lies in modifying the .gitconfig file to include the `useHttpPath = true` setting. This allows the credential helper to receive the full repository URL, including the owner portion. Inside the helper, the first element of the path is extracted and used to retrieve the corresponding PAT with the command `gh auth token --user ACCOUNT`.

When accessing a repository like `https://github.com/aont/foo.git`, the command `gh auth token --user aont` is executed automatically, retrieving the correct PAT for that account. Similarly, for `https://github.com/another-user/bar.git`, the command `gh auth token --user another-user` is invoked. This process eliminates the need to manually switch accounts or use external scripts.

It's important to note that the `helper =` line should be added to the .gitconfig file, resetting any previously configured credential helpers. This ensures that only this specific helper is used when dealing with multiple GitHub accounts.

The same approach can be applied to Git repositories, allowing for seamless credential management across different repositories and services. By configuring the credential helper based on the remote URL, you can treat GitHub repositories and Gists with the same rules, making the process more efficient and streamlined.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

A Confirm Button Is Not a Coding-Agent Security Boundary

A coding agent asks for permission to modify packages/web/generated/client.ts . The path looks harmless, the proposed diff sounds reasonable, and the user clicks Approve.

  • A confirm button alone does not define system security boundaries.
  • Approval must match execution for true security boundary functionality.
  • Binding approval to specific, invariant facts about the operation is required.

Data Sniffing: Threats to Business and 5 Ways to Defend

Data sniffing, or packet sniffing, is the covert interception and analysis of data as it moves across a network. While some sniffers serve legitimate purposes (for example, network troubleshooting by…

  • Sniffers intercept network data as digital eavesdroppers
  • Packet sniffing captures, reassembles, and analyzes packets
  • Multi-layered defense required: encryption, MFA, network segmentation

U.S. Seeks More Korean Chip Investment as Honam Project Advances

The U.S. government is seeking additional investment by South Korean semiconductor companies in U.S. memory production facilities, citing Korea's 800 trillion won, or approximately $577.45 billion…

  • U.S. seeks increased investment from South Korean semiconductor firms for Honam project.
  • Samsung Electronics and SK hynix mentioned by Commerce Secretary Howard Lutnick.
  • South Korean government asserts request is independent of $350 billion investment agreement.

More from Wednesday 26 August →