Java 在 IntelliJ IDEA 中更改 Git 用户

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28275397/
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-08-11 05:54:30  来源:igfitidea点击:

Change Git user in IntelliJ IDEA

javagitintellij-ideausername

提问by user4519506

My IntelliJ IDEA was used by another user and when I try to push to Git, I was asked a password of this user.

我的 IntelliJ IDEA 被另一个用户使用,当我尝试推送到 Git 时,我被要求输入该用户的密码。

How can I change user in my IDEA? I tried to change global Git user, but it is not working.

如何在我的 IDEA 中更改用户?我试图更改全局 Git 用户,但它不起作用。

回答by Codeversum

Go to File -> Settings -> Version Control -> GitHub and enter your Login and Password there.

转到文件 -> 设置 -> 版本控制 -> GitHub 并在那里输入您的登录名和密码。

回答by RE350

Go to below link.

转到以下链接。

File-->Settings--->Version Control -->GitHub

If you need to connect to Bitbucket, you need to change the host to bitbucket.org

如果需要连接Bitbucket,需要将主机改成bitbucket.org

回答by user4519506

I found a solution myself: just find hidden .git file in your project root, open it, and change user.

我自己找到了一个解决方案:只需在项目根目录中找到隐藏的 .git 文件,打开它,然后更改用户即可。

回答by Sergey Kolosov

Just change in terminal in IntelliJ Idea an URL of your project. Put yours instead of ${urlToYourProject}.

只需在 IntelliJ Idea 的终端中更改项目的 URL。把你的而不是${urlToYourProject}.

git remote set-url origin ${urlToYourProject}

Then update project (Ctrl+T). And you'll see the dialog where you can set your credentials.

然后更新项目 (Ctrl+T)。您将看到可以在其中设置凭据的对话框。

Don't forget that you can use other remote name instead of origin!

不要忘记您可以使用其他远程名称代替origin!

回答by Amaresh Narayanan

  1. Goto base directory of your project
  2. You will find a hidden directory called ".git" and enter into it
  3. There you will see file called "config" and add below code

    [user]
          name = username
          email = [email protected]
    
  1. 转到项目的基本目录
  2. 你会找到一个名为“.git”的隐藏目录并进入
  3. 在那里您将看到名为“config”的文件并添加以下代码

    [user]
          name = username
          email = [email protected]
    

回答by Ruwen

You can change it global via any of the 2 options.

您可以通过 2 个选项中的任何一个全局更改它。

  1. "Git Bash" which comes with the git installation package.
  2. In IntelliJ View > Tool Windows > Terminal (Alt + F12).
  1. git安装包自带的“Git Bash”。
  2. 在 IntelliJ 视图 > 工具窗口 > 终端(Alt + F12)中。

Use command :

使用命令:

git config --global user.name "John Doe"

回答by Kalinka

Go to VCS -> Git -> Remotes

There you can edited your git remotesby changing user in the URL https://user@serc-bitbucket.

在那里您可以git remotes通过更改 URL https://user@serc-bitbucket 中的用户来编辑您的。

In your next Push you'll be prompted to a dialog to enter your password, and in the next your credientials.

在您的下一次推送中,系统会提示您输入密码的对话框,并在接下来的提示中输入您的凭据。