Github push main error push失敗解決(報錯原因error: src refspec main does not match any)

Github push main失敗,報錯原因error: src refspec main does not match any,解決方式,修改master分支為main

報錯訊息

root@k8s-master71u:/data/docker-elk# git push -u origin main
error: src refspec main does not match any
error: failed to push some refs to 'https://github.com/chingtsechen/docker-elk.git'

解決方式: 修改master為main

root@k8s-master71u:/data/docker-elk# git init

# 這裡需要修改master為main
root@k8s-master71u:/data/docker-elk# git branch -m master main

root@k8s-master71u:/data/docker-elk# git add .

root@k8s-master71u:/data/docker-elk# git commit -m "first commit"

root@k8s-master71u:/data/docker-elk# git branch -M main

root@k8s-master71u:/data/docker-elk# git remote add origin https://github.com/chingtsechen/docker-elk.git

root@k8s-master71u:/data/docker-elk# git push -u origin main
Username for 'https://github.com': chingtsechen
Password for 'https://[email protected]': 
Enumerating objects: 85, done.
Counting objects: 100% (85/85), done.
Delta compression using up to 8 threads
Compressing objects: 100% (74/74), done.
Writing objects: 100% (85/85), 34.36 KiB | 3.12 MiB/s, done.
Total 85 (delta 11), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (11/11), done.
To https://github.com/chingtsechen/docker-elk.git
 * [new branch]      main -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.
comments powered by Disqus
使用 Hugo 建立
主題 StackJimmy 設計
發表了128篇文章 · 總計63.96k字
本站已運行
·