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

4

8

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.

Obtrusive answered 28/8, 2015 at 12:4 Comment(7)
Does this help you? Or maybe the git docs?Canister
Thanks for your answer. It helped, but what I am trying do is this : gist.github.com/jexchan/2351996 No matter what I do, I am not able to access my 2nd account - the account which was made later. 1. I created new SSH key for the second account. 2. Copied and added it to my second account. 3. Tried both - the method given by @Altius and in the above link. Both failed to push repository from my pc to the second account.Obtrusive
Have you seen also this?Canister
what you have are probably different github accounts, don't you? Then they have very little to do with the config, you can even have both accounts used for the same repository at same time.Binominal
after setting up ssh config try running ssh -v [email protected] and same for another account. Github does not allow shell access but you will see if logging in succeeds and which key is usedBinominal
Nope, nothing is working. Can anyone try to do the same from scratch i.e : create a second account at github and try to push repository on that using ssh keys / config file whatever needed.Obtrusive
Local or global config file ? subl ~/.gitconfigMilker
B
20

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

Buerger answered 18/2, 2022 at 1:45 Comment(0)
K
10
  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 "[email protected]"

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 "[email protected]"

Hope this would help your query

Krahmer answered 28/8, 2015 at 12:22 Comment(3)
Thanks I tried it, but it's not helping. I can see ssh keys configured to my previous account only whenever I pushed my repositories to the second account.Obtrusive
Remove the ssh key and then try.Krahmer
@Obtrusive remove all user from git configuration and then add each user to your repo. What it is giving now?Krahmer
I
3

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.

Intrauterine answered 29/1, 2021 at 6:21 Comment(0)
S
3

For mac users - You can just run this command

open ~/.gitconfig

Solve answered 22/11, 2022 at 15:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.