我有一个energys_arduino_max485_mqtt_autoconnect_ec400,的GitHub回购,但是我在把文件推到这个回购上有问题。
(base) Mac-Pro energys_arduino_max485_mqtt_autoconnect_ec400 % git remote add origin https://github.com/SamuelXiot/energys_arduino_max485_mqtt_autoconnect_ec400.git
error: remote origin already exists.
(base) Mac-Pro energys_arduino_max485_mqtt_autoconnect_ec400 % git branch -M main
(base) Mac-Pro energys_arduino_max485_mqtt_autoconnect_ec400 % git push -u origin main
error: src refspec main does not match any
error: failed to push some refs to 'https://github.com/SamuelXiot/energys_arduino_max485_mqtt_autoconnect_ec400.git.'
(base) Mac-Pro energys_arduino_max485_mqtt_autoconnect_ec400 % git remote remove origin
(base) Mac-Pro energys_arduino_max485_mqtt_autoconnect_ec400 % git remote add origin https://github.com/SamuelXiot/energys_arduino_max485_mqtt_autoconnect_ec400.git
(base) Mac-Pro energys_arduino_max485_mqtt_autoconnect_ec400 % git branch -M main
(base) esp32@Arthurs-Mac-Pro energys_arduino_max485_mqtt_autoconnect_ec400 % git push -u origin main
error: src refspec main does not match any
error: failed to push some refs to 'https://github.com/SamuelXiot/energys_arduino_max485_mqtt_autoconnect_ec400.git'
(base) Mac-Pro energys_arduino_max485_mqtt_autoconnect_ec400 % git push -u origin master
error: src refspec master does not match any
error: failed to push some refs to 'https://github.com/SamuelXiot/energys_arduino_max485_mqtt_autoconnect_ec400.git'
(base) Mac-Pro energys_arduino_max485_mqtt_autoconnect_ec400 % git pull --rebase
remote: Repository not found.
fatal: repository 'https://github.com/SamuelXiot/energys_arduino_max485_mqtt_autoconnect_ec400.git/' not found
(base) Mac-Pro energys_arduino_max485_mqtt_autoconnect_ec400 % git push
error: src refspec refs/heads/main does not match any
error: failed to push some refs to 'https://github.com/SamuelXiot/energys_arduino_max485_mqtt_autoconnect_ec400.git'为什么我不能推到GitHub??
发布于 2022-06-23 03:01:48
似乎你正在尝试一次上传你所有的代码到你在github的网站上做的空的回购。似乎您已经运行了git init
您需要首先使用git add .提交所有更改,然后使用git commit -m "comment you choose"提交更改,这样您就可以进行推送了。在这种情况下,你可能已经做了一个新的分支,你不需要一个分支。
git add .
git commit -m "first commit"
git remote add origin https://github.com/user/repo.git
git push
发布于 2022-06-23 03:56:15
最后找到了解决方案,我需要首先更新Mac中的GitHub帐户。
需要删除所有帐户凭据
$ git credential-osxkeychain erase
host=github.com
protocol=https
> [Press Return]创建PAT
然后更新终端中的git登录。
(底部)-Mac 485_mqtt_autoconnect % git为'https://github.com':SamuelXiot https://SamuelXiot@github.com'密码‘推原始用户名:枚举对象: 18,已完成。计数对象: 100% (18/18),完成。达美压缩使用多达8个线程压缩对象: 100% (12/12),完成。书写对象: 100% (18/18),3.22 KiB \ 1.07 MiB/s,已完成。总计18 (增量1),重用0(增量0),包重用0远程:解析三角洲: 100% (1/1),完成。转到https://github.com/SamuelXiot/485_mqtt_autoconnect.git
那就又正常了。
谢谢大家的帮助。
https://stackoverflow.com/questions/72723982
复制相似问题