微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐