【发布时间】: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 帐户时,我发现存储库已经创建但它是空的。
谁能帮帮我?
【问题讨论】: