【问题标题】:Push Changes to Git not Functioning将更改推送到 Git 不起作用
【发布时间】:2016-12-20 13:37:12
【问题描述】:

每次我想提交命令“git push heroku master”时,都会在 PowerShell 中要求我输入凭据。当我输入 heroku 凭据(默认连接到 git)时,我收到错误消息。

但是,当我在我的主目录中键入 netrc 文件中包含的凭据时,事物就会起作用。然而,在我看来,密码是散列的。如何避免每次将更改推送到 git 时都输入凭据?

更新:

PS C:\Users\Dragan\heroku_workspace\python-getting-started> git push heroku master
github --credentials get: github: command not found
Username for 'https://git.heroku.com': my-email@hotmail.com
Password for 'https://my-email@hotmail.com@git.heroku.com':
github --credentials erase: github: command not found
remote: !       WARNING:
remote: !       Do not authenticate with username and password using git.
remote: !       Run `heroku login` to update your credentials, then retry the git command.
remote: !       See documentation for details: Https://devcenter.heroku.com/articles/http-git#authentication
fatal: Authentication failed for 'https://git.heroku.com/mysterious-river-71834.git/'

【问题讨论】:

  • 您收到的错误信息是什么?你应该只需要heroku login 一次。
  • @Harrison 使用我的 heroku 凭据使用命令和 heroku 登录功能。但是,当我输入与以前相同的凭据时,命令 git pushe heroku master 不会。它仅在我输入在 netrc 文件中找到的散列密码时起作用,除此之外,我每次想要执行 git push 时都必须这样做......错误消息在我更新的问题描述中问题。

标签: windows git github heroku


【解决方案1】:

一个常见的错误是使用默认 (HTTPS) 而不是 SSH 进行克隆。您可以通过转到您的存储库,单击 URL 字段左侧的 ssh 按钮并更新源远程的 URL 来更正此问题,如下所示:
git remote set-url origin git@github.com:username/repo.git

或者如果您的存储库已经点击绿色按钮CLONE OR DOWNLOAD 并选择使用SSH

启用 SSH 身份验证

$ heroku create --ssh-git

将高 HTTPS 调用重定向到 SSH ( If you want to always use SSH Git with Heroku on a particular machine)

$ git config --global url.ssh://git@heroku.com/.insteadOf https://git.heroku.com/

生成公钥:

ssh-keygen -t rsa 在出现第一个提示时按回车键使用默认文件位置。接下来,输入密钥的安全密码。

【讨论】:

  • 你能说得更具体些吗?我到底需要在哪里从 https 切换到 ssh?
  • 1.如果你去 github 网站和Login 2. 去你的存储库主页。 3. 然后在RIGHT-SIDE 你会看到一个GREEN BUTTON 上面写着CLONE OR DOWNLOAD 点击它
  • 我找到了可以从 https 切换到 ssl 的位置,但是,上述情况下的 git 存储库是由 heroku 自动创建的,我不知道在哪里可以找到那个。这是链接:git.heroku.com/mysterious-river-71834.git
  • 你需要1 create ssh-git然后2 tell heroku to use ssh instead of hhtp in your computer,你可能需要3 Create a key 这里是[链接到密钥](devcenter.heroku.com/articles/keys
【解决方案2】:

如果您使用的是v1.9.3或更高版本Git for Windows,您可以执行以下操作

git config --global credential.helper wincred

请注意,此机制将您的用户名/密码存储在 Windows Credential Store 中。

在相对较新的版本中,Git Credential Manager for WindowsGit for Windows 捆绑在一起并默认启用,您可能需要为 Heroku 覆盖 credential.helper 配置。 GCM 似乎是为 VSTS 和 GitHub 设计的,我不是它与其他服务器的行为方式。

【讨论】:

    【解决方案3】:

    为我工作:

    1. 使用 Windows 命令提示符 cmd.exe 运行 heroku login。这会将您的 API 密钥放入您的 _netrc,此时您可以打开 cygwin 或 git bash 并执行您需要的任何操作

    2. .gitconfig 中删除helper = manager 行,这样它就不再注册为凭证助手并阻止它出现。

      (在C:\Users\username\.gitconfig

    3. 在 Windows 7 的用户目录中将 _netrc 文件重命名为 .netrc:

      cd %home%

      REN _netrc .netrc

    见:

    'git push heroku master' is still asking for authentication

    https://github.com/heroku/cli/issues/84#issuecomment-170689175

    【讨论】:

      猜你喜欢
      • 2015-05-28
      • 2013-08-21
      • 1970-01-01
      • 1970-01-01
      • 2018-02-28
      • 1970-01-01
      • 2011-03-12
      • 2016-06-12
      • 1970-01-01
      相关资源
      最近更新 更多