Skip to content


If you find yourself having to change remotes of a repo in order to authenticate as the correct user, then perhaps you should consider using gh as your credential manager.

  • Run gh auth setup-git (reference).
  • Run gh auth login to login with however many accounts you have
  • Run gh auth switch to switch the current account
  • With this method, you don’t need ssh-add in your shell’s rc file.
  • Note that if this doesn’t work with an error like this: ERROR: Permission to Adam13531/AdamsApple.git denied to AdamLearns., then perhaps try changing your remote to be HTTPS rather than SSH.
  • Note that if you get an error about scopes (e.g. ! [remote rejected] main -> main (refusing to allow an OAuth App to create or update workflow `.github/workflows/produce-docker-image.yml` without `workflow` scope), you can login with the right scopes:
    • gh auth login --scopes workflow
  • List all PRs: gh pr list
  • Start working locally on a PR: `gh pr checkout PR_NUMBER
    • The next thing you should do isn’t gh-specific, but you should update the PR branch with either rebase or a merge. rebase will rewrite the history and require a force-push since the base branch is in another repo. Merging can be done with git merge --no-ff main and will have the same effect without rewriting history.
  • Finish working on a PR: git push
  • Merge the PR on GitHub or via gh pr merge (without an argument, it will use the current branch). I prefer using GitHub for this.

Full error:

╰─❯ git push
! [rejected] smu-face-last-dir -> smu-face-last-dir (non-fast-forward)
error: failed to push some refs to ''
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

This happens from the following flow:

  • gh pr checkout PR_NUMBER
  • git pull origin main --rebase
  • git push The reason is that I’m pulling in my origin even though I’m working in someone else’s repo.