Varun verma
Varun verma

Reputation: 189

how to change the username in git?

I know its a common question, but even after apply various solutions I'm still not able to change the username. every time when i try to push my changes on git, i'm getting below error.

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

I tried below command as well.

git config credential.username "varun9777"

But still getting the same error at the time of push only.

I want to change the username abc-xyz to varun9777

Please help. Thanks in advance.

Upvotes: 3

Views: 5378

Answers (6)

Sourav Dutta
Sourav Dutta

Reputation: 1332

Try these in a series

git remote set-url origin https://varun9797:[email protected]/varun9797/BetterWorldUI.git
git config --global user.email "[email protected]"
git config --global user.name "varun verma"
git config --global credential.username "varun9797"

go to your .git folder, then open config file. In the file paste your user info:

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

Upvotes: 1

DevPro
DevPro

Reputation: 511

Try this one:

git remote set-url origin https://[email protected]/user/BetterWorldUI.git 

where username should be varun9797

Upvotes: 0

Matt Clark
Matt Clark

Reputation: 28639

Try setting your username in the remote connection string:

$ git remote -v
https://github.com/varun9797/BetterWorldUI.git/

$ git remote remove origin

$ git remote add origin https://[email protected]/varun9797/BetterWorldUI.git/

Now when you try a push / pull it should prompt you for a password.

Upvotes: 0

torek
torek

Reputation: 489828

The problem is that there is not a the user name. There are many user names.

There is a user.name you can set in your Git configuration. This sets the name put into new commits that you make. It generally has no other function, though any program can query it at any time and make any use of it that this other program (whatever it is) wants.

There is a user-name embedded in some URLs:

git push ssh://[email protected]/path/to/repo.git

embeds the user name joe into the SSH URL, and:

git fetch https://user:[email protected]/path/to/repo.git

embeds both the user name user and his password (not generally wise).

Your own suggestion of credential.username appears not to be used by anything, though since anyone can write any program at any time that uses any string for any purpose, perhaps someone has done so—but a Google search for credential.username turns up mostly pages like https://sysadminguides.org/2017/05/02/how-to-pass-credentials-in-powershell/ that are not about Git at all.

The Pro Git book suggests that on Windows, you may wish to install Git Credential Manager for Windows.

In any case, once you have installed some credential helper, or chosen to use one of those built in to Git itself, you select which credential helper to use via git config --global credential.helper helper. It's not at all clear from your question which credential helper you are using now; but whichever one you are using, that determines what setting you need to change.

Upvotes: 0

Wang Liang
Wang Liang

Reputation: 4444

git remote set-url origin https://varun9797:[email protected]/varun9797/BetterWorldUI.git

We can set repository url that contains git credentials.

Upvotes: 2

Try user.name instead.

For detailed description follow the link: https://confluence.atlassian.com/bitbucket/configure-your-dvcs-username-for-commits-950301867.html

Upvotes: 0

Related Questions