如何使用 github api 从 official/master 中提取经过身份验证的用户?

How to pull from official/master using github api for authenticated user?

我有 oauth2 access_token 用于范围回购的用户,这意味着我基本上可以访问用户的所有 public/private 回购。 我的机器上有一个 repo 的本地副本,我想使用 github api.
中经过身份验证的用户令牌来提取(获取和合并)我该如何管理?

你不能在本地做,但我认为可以从 docs

git pull is shorthand for git fetch followed by git merge FETCH_HEAD

您可以按照以下步骤依次完成

  1. 创建branch
  2. 新建一个commmit
  3. update 分支指向新提交
  4. merge 您要拉入的新创建分支

OAuth 访问令牌,(例如 PAT (Personal Access Token)) can be used from command-line

当 GitHub 要求您提供用于 HTTPS URL 的凭据 (username/password) 时,该 OAuth 令牌可用作密码 URL。

因此,请确保远程 URL 是一个 HTTPS,其中包含 <theuser> 用户名

    cd /path/to/repo
    git remote -v
    # if origin starts with git@github.com (SSH)
    git remote set-url origin https://<theuser>@github.com/<theuser>/<repo>

每当您 clone/pull/push 来自 <theuser> 的私有存储库时,输入 OAuth 访问令牌作为密码。

或者检查你的git config credential.helper:你可以cache those credentials, using for instance the GCM (Git Credential Manager) like one for Mac/Linux, or for Windows

请注意,git merge 是仅限本地的操作,因此不需要任何凭据。