【问题标题】:How to push code using Github API?如何使用 Github API 推送代码?
【发布时间】:2015-06-01 10:50:59
【问题描述】:

我想通过 nodejs 应用将目录推送到 Github。这是我目前所做的。 我从用户那里获取用户名、密码和新的存储库名称。然后,我通过 Github API(https://developer.github.com/v3/repos/#create) 创建新的存储库。 现在我想将一些特定的代码推送到这个存储库。我不能使用 node.js 子进程(git push origin master),因为这需要用户名和密码。 如何通过 API 将代码推送到 Github。 (如果通过命令行,则无需手动输入密码)

【问题讨论】:

  • 你能详细说明一下完整的过程吗?
  • 如果你使用ssh密钥,你可以使用命令行不用输入密码。

标签: node.js git github git-push


【解决方案1】:

要在每次提交时跳过密码,您需要告诉 git 将凭证存储在单独的位置。这可以通过使用以下命令来完成:

git config --global credential.helper cache

这将存储密码for 15 minutes。如果您希望可以通过指定持续时间(以毫秒为单位)来延长此时间:

git config --global credential.helper "cache --timeout=3600"

【讨论】:

  • 如果你详细说明可能会更好
  • 我有 node-angular 应用程序,我通过 UI 询问用户他的 github 用户名和密码。现在在后端,我想将一些代码推送到用户的 github 帐户。
猜你喜欢
  • 2017-11-04
  • 1970-01-01
  • 2020-07-17
  • 1970-01-01
  • 2011-09-14
  • 1970-01-01
  • 2021-11-08
  • 2022-07-05
  • 1970-01-01
相关资源
最近更新 更多