error: src refspec main does not match any.

生成ssh key

ssh-keygen -t rsa -C "mag@126.com" -f github.ssh

 

*** Please tell me who you are.

root@ubuntu:/home/ubuntu/test/mini-riscv-os# git add .
root@ubuntu:/home/ubuntu/test/mini-riscv-os# git commit -m "my mini-riscv-os"

*** 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 'root@ubuntu.(none)')
root@ubuntu:/home/ubuntu/test/mini-riscv-os# git config --global user.name "mag"
root@ubuntu:/home/ubuntu/test/mini-riscv-os# git commit -m "my mini-riscv-os"

*** 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 'root@ubuntu.(none)')
root@ubuntu:/home/ubuntu/test/mini-riscv-os# git config --global user.email "mag@126.com"
root@ubuntu:/home/ubuntu/test/mini-riscv-os# git commit -m "my mini-riscv-os"
[master (root-commit) a7b0d18] my mini-riscv-os
 215 files changed, 13356 insertions(+)
 create mode 100644 .DS_Store
 create mode 100644 .gitignore
 create mode 100644 01-HelloOs/Makefile

 

 

 

 error: src refspec main does not match any.

解决方式:(方法不唯一,仅供参考)

统一远程和本地的仓库名称即可

1、把本地的 master 仓库名称修改为远端的 main

重命名命令: git branch -m oldBranchName newBranchName

root@ubuntu:/home/ubuntu/test/mini-riscv-os# git remote add origin git@github.com:/mini-riscv-os-test.git
root@ubuntu:/home/ubuntu/test/mini-riscv-os# git push -u origin main
error: src refspec main does not match any.
error: Failed to push some refs to 'git@github.com:/mini-riscv-os-test.git'
root@ubuntu:/home/ubuntu/test/mini-riscv-os# git push -u origin main
error: src refspec main does not match any.
error: Failed to push some refs to 'git@github.com:/mini-riscv-os-test.git'
root@ubuntu:/home/ubuntu/test/mini-riscv-os# git push -u origin main -f
error: src refspec main does not match any.
error: Failed to push some refs to 'git@github.com:/mini-riscv-os-test.git'
root@ubuntu:/home/ubuntu/test/mini-riscv-os# git branch
* master
root@ubuntu:/home/ubuntu/test/mini-riscv-os#  git branch -m master main
root@ubuntu:/home/ubuntu/test/mini-riscv-os# git push -u origin main 
^C
root@ubuntu:/home/ubuntu/test/mini-riscv-os# ssh-agent bash
root@ubuntu:/home/ubuntu/test/mini-riscv-os# ssh-agent  add ../ssh/github.ssh
add: No such file or directory
root@ubuntu:/home/ubuntu/test/mini-riscv-os# ssh-add ../ssh/github.ssh
Identity added: ../ssh/github.ssh (../ssh/github.ssh)
root@ubuntu:/home/ubuntu/test/mini-riscv-os# git push -u origin main

 

相关文章

本篇内容主要讲解“gitee如何上传代码”,感兴趣的朋友不妨来...
这篇“从gitee上下的代码如何用”文章的知识点大部分人都不太...
这篇文章主要介绍“gitee如何下载仓库里的项目”,在日常操作...
本篇内容主要讲解“怎么在Gitee上更新代码”,感兴趣的朋友不...
本文小编为大家详细介绍“怎么将工程托管到gitee”,内容详细...
这篇文章主要介绍了gitee中图片大小如何调整的相关知识,内容...