在 Visual Studio Code 中更改 git 用户

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42318673/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:49:03  来源:igfitidea点击:

Changing the git user inside Visual Studio Code

gitvisual-studio-code

提问by apxp

The user for my git commits has changed, but I am not able to change that inside of Visual Studio Code.

我的 git 提交的用户已更改,但我无法在 Visual Studio Code 中更改该用户。

I changed the global settings in git, but when I want to push or sync via Visual Studio Code inside my new repos I get the error that the oldusernamehas not the permission to push into newrepository. At this point it is not the permission. The change of the username did not work for visual studio code. When I use the terminal I can push. It is also not a solution to allow the olduserto push to the newrepository.

我更改了 git 中的全局设置,但是当我想在我的新存储库中通过 Visual Studio Code 推送或同步时,我收到错误,说oldusername没有推送到newrepository的权限。在这一点上它不是许可。用户名的更改不适用于 Visual Studio 代码。当我使用终端时,我可以推送。这也不是允许olduser推送到newrepository的解决方案。

I am on Windows 10. So all other tools are working, but just at Visual Studio Code I was not able to change the user.

我使用的是 Windows 10。所以所有其他工具都可以使用,但仅在 Visual Studio Code 中我无法更改用户。

Any recomondations are welcome.

欢迎任何建议。

回答by Gregory Thomas

I resolved this issue by setting an email address in Git:

我通过在 Git 中设置电子邮件地址解决了这个问题:

git config --global user.email "[email protected]"

回答by Pulkit

Press Ctrl + Shift + G in Visual Studio Code and go to more and select Show git output. Click Terminal and type git remote -vand verify that the origin branch has latest username in it like:

在 Visual Studio Code 中按 Ctrl + Shift + G 并转到更多并选择Show git output. 单击终端并键入git remote -v并验证源分支中是否具有最新的用户名,例如:

origin [email protected]:DroidPulkit/Facebook-Chat-Bot.git (fetch)

origin [email protected]:DroidPulkit/Facebook-Chat-Bot.git(获取)

origin [email protected]:DroidPulkit/Facebook-Chat-Bot.git (push)

origin [email protected]:DroidPulkit/Facebook-Chat-Bot.git(推送)

Here DroidPulkit is my username.

这里 DroidPulkit 是我的用户名。

If the username is not what you wanted it to be then change it with:

如果用户名不是您想要的,则使用以下命令进行更改:

git add remote origin [email protected]:newUserName/RepoName.git

回答by Ram

Generally VSCode uses the github credentials from system's credential manager, it doesn't store anywhere in the settings. As question says Changing the git user inside Visual Studio Code, is not insiderather outside.

通常 VSCode 使用来自系统凭据管理器的 github 凭据,它不会存储在设置中的任何位置。如题所说Changing the git user inside Visual Studio Code不在里面,在外面

Search for or Go to credential manager (Windows control panel) -> Windows Credentials -> Update the GitHub password from the list.

搜索或转到凭据管理器(Windows 控制面板)-> Windows 凭据-> 从列表中更新 GitHub 密码。

回答by Darpan

This could be because of the reason that the credentials are saved and you need to update those credentials and you can do that by following the below steps

这可能是因为保存了凭据并且您需要更新这些凭据,您可以按照以下步骤进行操作

control panel-> credential manager ->under generic credential you will be able to see the credentials related to git

控制面板-> 凭据管理器-> 在通用凭据下,您将能够看到与 git 相关的凭据

Try to update them if that does not work delete them and add new ones

如果不起作用,请尝试更新它们删除它们并添加新的

for other platforms or different versions of the operating system you need to find out where the credentails are saved related to git and update them.

对于其他平台或不同版本的操作系统,您需要找出与 git 相关的凭证的保存位置并更新它们。

回答by Diogo PEREIRA MARQUES

I had the same problem as Daniel, setting the commit address and unsetting the credentials helper also worked for me.

我和 Daniel 遇到了同样的问题,设置提交地址和取消设置凭据助手也对我有用。

git config --global user.email '<git-commit-address>'
git config --global --unset credential.helper

回答by Metin Yavuz

There is a conflict between Visual Studio 2015 and Visual Studio Code for the git credentials. When i changed my credentials on VS 2015 VS Code let me push with the correct git ID.

对于 git 凭据,Visual Studio 2015 和 Visual Studio Code 之间存在冲突。当我在 VS 2015 VS Code 上更改我的凭据时,让我使用正确的 git ID 推送。

回答by Usama nadeem

I was facing the same issue tried multiple options but didn't work for me. Then i tried this method https://stackoverflow.com/a/39608906and it perfectly worked for me (Thanks to Venkataramana Madugula). Hope it will help you. Visit the link and follow the steps. You just need to remove the github from the list.

我遇到了同样的问题,尝试了多种选择,但对我不起作用。然后我尝试了这个方法https://stackoverflow.com/a/39608906,它对我来说非常有效(感谢 Venkataramana Madugula)。希望它会帮助你。访问链接并按照步骤操作。您只需要从列表中删除 github。

回答by Mohamed Ghoubali

From VSCode Commande Palette select :

从 VSCode Commande Palette 中选择:

GitHub Pull Requests : Sign out of GitHub.

GitHub 拉取请求:退出 GitHub。

Then Sign in with your new credential.

然后使用您的新凭据登录。

回答by Mohsin Mahmood

You can view all of your settings and where they are coming from using:

您可以使用以下方法查看所有设置及其来源:

git config --list --show-origin

Delete the unwanted credentials from the directory and then VSCode ask you for the next time you perform git operation.

从目录中删除不需要的凭据,然后 VSCode 会在您下次执行 git 操作时询问您。