Node.js git simple:致命:无法自动检测电子邮件地址

Node.js git simple:致命:无法自动检测电子邮件地址,node.js,git,Node.js,Git,我正在尝试使用git simple包进行提交 其思想是使用github api提供的令牌进行身份验证,创建远程存储库,创建.gitignore,然后创建安装文件 下面是我运行脚本的代码 const run = async () => { try { // Retrieve & Set Authentication Token const token = await getGithubToken(); github.githubAuth(token); // Create remo

我正在尝试使用git simple包进行提交

其思想是使用github api提供的令牌进行身份验证,创建远程存储库,创建.gitignore,然后创建安装文件

下面是我运行脚本的代码

const run = async () => {
try {
// Retrieve & Set Authentication Token
const token = await getGithubToken();
github.githubAuth(token);

// Create remote repository
const url = await repo.createRemoteRepo();

// Create .gitignore file
await repo.createGitignore();

// Setup local repository and push to remote
const done = await repo.setupRepo(url);

if(done) {
  console.log(chalk.green('All done!'));
}
} catch(err) {
  if (err) {
    switch (err.code) {
      case 401:
        console.log(chalk.red('Couldn\'t log you in. Please provide correct credentials/token.'));
        break;
      case 422:
        console.log(chalk.red('There already exists a remote repository with the same name'));
        break;
      default:
        console.log(err);
    }
  }
 }
}
在执行repo.setuprepoorl之前,一切正常

    setupRepo : async(url) =>{
    const status = new Spinner('Initializing local repository and pushing to remote...')
    status.start()

    try{
        await git
            .init()
            .add('.gitignore')
            .add('./*')
            .commit('initial commit')
            .addRemote('origin',url)
            .push('origin','master')
        return true
    }
    catch(err){
        console.log(err)
    }
    finally{
        status.stop()
    }
}
下面是setupRepourl的代码

    setupRepo : async(url) =>{
    const status = new Spinner('Initializing local repository and pushing to remote...')
    status.start()

    try{
        await git
            .init()
            .add('.gitignore')
            .add('./*')
            .commit('initial commit')
            .addRemote('origin',url)
            .push('origin','master')
        return true
    }
    catch(err){
        console.log(err)
    }
    finally{
        status.stop()
    }
}
我得到了这个信息:

 Git#then is deprecated after version 1.72 and will be removed in version 2.x
 Please switch to using Git#exec to run arbitrary functions as part of the 
 command chain.

 / Initializing local repository and pushing to remote...
 *** Please tell me who you are.

 Run

 git config --global user.email "you@example.com"
 git config --global user.name "Your Name"

 to set your account's default identity.
 Omit --global to set the identity only in this repository.

 fatal: unable to auto-detect email address (got 'Anes@DESKTOP-E9U575A.
(none)')

| Initializing local repository and pushing to remote...
当我打开我的github帐户时,我发现存储库已经创建,但它是空的


有人能帮我吗?

我也有这个问题

如何解决? 请参阅下面的代码,将ssh\u url更改为clone\u url

    createRemoteRepo: async () => {
    const github = gh.getInstance();
    const answers = await inquirer.askRepoDetails();

    const data = {
        name: answers.name,
        description: answers.description,
        private: (answers.visibility === 'private')
    };

    const status = new Spinner('Creating remote repository...');
    status.start();

    try {
        const response = await github.repos.create(data);
        // return response.data.ssh_url;
        return response.data.clone_url;
    } catch (err) {
        throw err;
    } finally {
        status.stop();
    }
}
详细答复见此处

为什么? 区别:SSH和https

其他解决方案,但我没有试验

ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
可能重复的