简体   繁体   中英

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

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.

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

The answer given by @Altius and here: 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.

  1. Navigate to your git repo
  2. enter to .git folder -> cd .git
  3. Open the config file as vi config
  4. Add the following

[user] name = YOUR_USER_NAME email = YOUR_EMAIL

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

* **Another way to set username and email to specific 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 "your_email@example.com"

To set usernme as globally

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

It will give you present git configuration status.

You can set username as global

git config --global user.name "User_Name" git config --global user.email "your_email@example.com"

Hope this would help your query

Answer is

git config --global -e

it will open .gitconfig file in your default editor that you should have configured for git.

git-config

Table 4. Exhaustive list of core.editor configuration commands

Here is a simple step that I used to edit my git/config file

  1. Open a terminal of your choice. You can also use the shortcut key Ctrl+Alt+T to open a terminal.
  2. In your terminal type : git config --global --edit It will open your global configuration file of git in your default editor.
  3. Change the Settings that you want.

For more info on git config, you can check the entire manual by typing git config --help in your terminal.

For mac users - You can just run this command

open ~/.gitconfig

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM