【问题标题】:git push user id not changinggit push 用户 id 没有改变
【发布时间】:2017-06-29 05:16:24
【问题描述】:

我有两个 git ID("theNameBeforeIUsed", "correctName"), 我想改变我的会话。

所以我输入了, $ git config user.email correctmail@email.com $ git config --global user.email correctmail@email.com $ git config user.name "correctName" $ git config --global user.name "correctName" $ git push origin master

但是,发生了权限错误 remote: Permission to ~~~.git denied to theNameBeforeIUsed. fatal: unable to access '~~~.git/': The requested URL returned error: 403

如何退出“theNameBeforeIUsed”并使用“正确名称”登录?

【问题讨论】:

标签: git permissions config


【解决方案1】:

可能当您克隆存储库时,您会使用类似这样的东西 theNameBeforeIUsed@yourgit.com:proyect.git

因此,如果您在连接到 git 时更改用户,它将使用 theNameBeforeIUsed 而不是新用户,那么您需要更改文件 .git/config

以及它说的地方

[remote "origin"]
    url = theNameBeforeIUsed@yourgit.com:project.git

使用您项目的 https 版本或更改您的用户,我个人更喜欢 https,因为它更安全,并且总是要求您的用户避免误解

【讨论】:

  • 当我输入 git remote show origin 时,它会显示 Push URL: https://github.com/~~/~~.git
  • 仍然检查文件
  • [core] repositoryformatversion = 0 filemode = false bare = false logallrefupdates = true symlinks = false ignorecase = true [remote "origin"] url = github.com/~~~/~~~.git fetch = +refs/heads/*:refs /remotes/origin/* [user] name = correctName email = correctEmail@email.com
  • url 没有用户名@等前缀
  • 所以您的 git 每次推送或拉取时都会要求提供凭据,不是吗?检查您是否在github.com/settings/keys上设置了 ssh 密钥
猜你喜欢
  • 2018-05-26
  • 2013-05-01
  • 2023-03-04
  • 1970-01-01
  • 2021-12-31
  • 2012-11-11
  • 2020-03-17
  • 2020-04-15
  • 2020-04-14
相关资源
最近更新 更多