如何从命令提示符打开 git 配置文件 - git shell?

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

How to open git config file from command prompt - git shell?

gitgithubcommandconfigcommand-prompt

提问by

I am using multiple git accounts from the same computer. I want to change settings for the accounts. Searched google, but wasn't able to find the command that helps to open the config file.

我在同一台计算机上使用多个 git 帐户。我想更改帐户的设置。用谷歌搜索,但无法找到有助于打开配置文件的命令。

EDIT : It looks like there are different ways and config files to access github.

编辑:看起来有不同的方式和配置文件来访问 github。

The answer given by @Altius and here : gist.github.com/jexchan/2351996

@Altius 和这里给出的答案:gist.github.com/jexchan/2351996

I tried both - after setting up SSH keys for my second account, but both failed to push repository to my second account , but I can see repositories being pushed to my first - default account irrespective of what changes I make to any of the config files.

我尝试了两个 - 在为我的第二个帐户设置 SSH 密钥后,但都未能将存储库推送到我的第二个帐户,但我可以看到存储库被推送到我的第一个 - 默认帐户,无论我对任何配置文件进行了哪些更改.

回答by royki

  1. Navigate to your git repo
  2. enter to .gitfolder -> cd .git
  3. Open the configfile as vi config
  4. Add the following
  1. 导航到您的 git 存储库
  2. 进入.git文件夹->cd .git
  3. 打开config文件为vi config
  4. 添加以下内容

[user] name = YOUR_USER_NAME email = YOUR_EMAIL

[user] name = YOUR_USER_NAME email = YOUR_EMAIL

In your each repository, you can have different git@Userand associated git@email

在您的每个存储库中,您可以拥有不同git@User且关联的git@email

* **Another way to set username and email to specific git repo

* **另一种将用户名和电子邮件设置为特定 git repo 的方法

To set your username for a specific repository, enter the following command in the root folder of your repository: -

要为特定存储库设置用户名,请在存储库根文件夹中输入以下命令:-

git config user.name "User_Name" git config user.email "[email protected]"

git config user.name "User_Name" git config user.email "[email protected]"

To set usernme as globally

将用户名设置为全局

Open your console and run the following - git config --list

打开您的控制台并运行以下命令 - git config --list

It will give you present git configuration status.

它将为您提供当前的 git 配置状态。

You can set usernameas global

您可以设置username全局

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

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

Hope this would help your query

希望这对您的查询有所帮助