如何在git中更改用户名?

时间:2019-05-05 17:21:59

标签: git github ssh gitlab

我知道这是一个常见问题,但是即使应用了各种解决方案,我仍然无法更改用户名。每次当我尝试在git上进行更改时,我都会遇到错误。

PS C:\storage\class\11-1\Angular> git push origin DevBW-AngularAws remote: Permission to varun9797/BetterWorldUI.git denied to shivam-perpetualny. fatal: unable to access 'https://github.com/varun9777/BetterWorldUI.git/': The requested URL returned error: 403

我也尝试了以下命令。

git config credential.username "varun9777"

但仅在推送时仍会遇到相同的错误。

我想将用户名shivam-perptualny更改为varun9777

请帮助。 预先感谢。

6 个答案:

答案 0 :(得分:1)

git remote set-url origin https://varun9797:yourPassword@github.com/varun9797/BetterWorldUI.git

我们可以设置包含git凭据的存储库网址。

答案 1 :(得分:0)

尝试使用user.name。

有关详细说明,请单击链接: https://confluence.atlassian.com/bitbucket/configure-your-dvcs-username-for-commits-950301867.html

答案 2 :(得分:0)

尝试一系列操作

git remote set-url origin https://varun9797:yourPassword@github.com/varun9797/BetterWorldUI.git
git config --global user.email "verma9797@gmail.com"
git config --global user.name "varun verma"
git config --global credential.username "varun9797"

转到您的 .git 文件夹,然后打开 config 文件。在文件中粘贴您的用户信息:

[remote "origin"]
    url = https://github.com/varun9797/BetterWorldUI.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[user]
    name = varun-verma
    email = verma9797@gmail.com

答案 3 :(得分:0)

问题是没有 the 用户名。有许多用户名。

您可以在Git配置中设置一个user.name。这将设置您输入的 new 提交中的名称。它通常没有其他功能,尽管任何程序都可以随时查询它并充分利用其他程序(无论它是什么)想要的功能。

某些URL中嵌入了一个用户名:

git push ssh://joe@example.com/path/to/repo.git

将用户名joe嵌入到SSH URL中,并且:

git fetch https://user:password@host.example.com/path/to/repo.git

嵌入用户名user和他的密码(通常不明智)。

您自己对credential.username的建议似乎没有被任何人使用,尽管由于任何人都可以随时编写使用任何目的使用任何字符串的任何程序,也许有人这样做了,但是Google搜索{ {1}}出现了诸如https://sysadminguides.org/2017/05/02/how-to-pass-credentials-in-powershell/之类的页面,这些页面根本与Git无关。

在Windows上的Pro Git book suggests,您可能希望安装Windows的Git Credential Manager。

无论如何,一旦您安装了某些凭据帮助程序,或选择使用Git本身内置的凭据帮助程序之一,就可以通过credential.username选择要使用的哪个凭据帮助程序。从您的问题中并不清楚您现在正在使用哪个凭据助手;而无论您正在使用哪个凭据助手, 都会确定您需要更改哪些设置。

答案 4 :(得分:0)

尝试在远程连接字符串中设置用户名:

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

struct stat st = {0};

if (stat("/some/directory", &st) == -1) {
    mkdir("/some/directory", 0700);
}

现在,当您尝试进行推/拉操作时,它会提示您输入密码。

答案 5 :(得分:0)

尝试这个:

git remote set-url origin https://username@github.com/user/BetterWorldUI.git 

其中username应该是varun9797

相关问题