question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

get user and email from $HOME/.gitconfig

See original GitHub issue

this is the code, and the console.log() prints undefined。 But i can get the email value use ‘git config user.email’ in shell

async function f () {
    let value = await git.config(Object.assign({
        path: 'user.email',
    }, repo));

    console.log(value); 
}

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:15 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
brettz9commented, Sep 22, 2019

FWIW, I’m using the following workaround for Node:

const parseGitConfig = require('parse-git-config');
const getGitConfigPath = require('git-config-path');

exports.getGlobalGitAuthorInfo = async () => {
  const globalGitConfigPath = getGitConfigPath('global');
  const parsedConfig = await parseGitConfig({
    path: globalGitConfigPath
  });
  return parsedConfig;
};

I then use it by trying a regular commit without any author info supplied to commit, and if that errs, I use the following (with try-catches omitted):

const {user: {name: globalGitAuthorName, email: globalGitAuthorEmail}} = await getGlobalGitAuthorInfo();
 
await commit({repositoryPath, author: {
    name: globalGitAuthorName,
    email: globalGitAuthorEmail
}});
1reaction
wmhiltoncommented, May 26, 2018

Is the value defined locally, in .git/config or globally in ~/.gitconfig? Right now isomorphic-git can only read the local repo config file, not the one in the home directory. (I haven’t figured out what the “home directory” would be in a browser environment.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to show or change your Git username or email address
How to show or change your Git username or email address · 1) The `git config` command. Here's the git config command to...
Read more >
git config - How to know the git username and email saved ...
On windows, type git config --list | findstr user.name . This will give you user.name only. Share.
Read more >
How to show or change your Git username or email address ...
Let's examine each of these show your git username basics: #1 – Use the command, git config -get [user.name | user.email] git config...
Read more >
How to get git config username and email - Brainstorm Creative
I'll explain in this post how to get your git config user.name and user.email using the git config command so that you don't...
Read more >
How set git config username and email fields in global and ...
If you want to use a special name or email address for a specific Git repo, you can set the git config email...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found