iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
💭

Workflow for temporarily switching GitHub users to create and push a repository

に公開

Taking a note here since I always forget.

  1. Run git init in the directory you want to push
  2. Change the local config to the information of the other user you want to switch to temporarily
git config --local user.name [Other user's ID]
git config --local user.email [Other user's email]
  1. In this state, run git add . && git commit -m "initial commit"
  2. Create a new repository on this other user's GitHub account
  3. Create a Personal Access Token (PAT) with push permissions for the repository on this other user's GitHub account
  4. Enter the following
git remote add origin https://[Other user's ID]:[Other user's PAT]@github.com/[Other user's ID]/[repository-name].git
  1. git push origin main

Discussion