【问题标题】:git-simple : fatal: unable to auto-detect email addressgit-simple:致命:无法自动检测电子邮件地址
【发布时间】:2018-02-19 17:24:12
【问题描述】:

我正在尝试使用包 "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.setupRepo(url)

这里是 setupRepo(url) 的代码

    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 帐户时,我发现存储库已经创建但它是空的。

谁能帮帮我?

【问题讨论】:

标签: node.js git


【解决方案1】:

我也有这个问题。

如何解决?

看下面的代码,把 ssh_url 改成 clone_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();
    }
}

详细回复见这里create repo

为什么?

区别:SSH和https。Which remote URL should I use?

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

ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts

【讨论】:

    猜你喜欢
    • 2014-10-29
    • 2021-06-08
    • 2021-06-30
    • 1970-01-01
    • 2015-12-06
    • 1970-01-01
    • 2013-02-28
    • 2012-04-08
    • 1970-01-01
    相关资源
    最近更新 更多