git - 将代码推送到 github 公共驱动器时出错
问题描述
我是 github 的新手,正在尝试创建我的第一个存储库。执行以下命令后:
$ git push -u origin master
我收到以下错误:
error: src refspec master does not match any.
error: failed to push some refs to 'https://github.com/rs/python-gtts.git
我做过的几件事,
在我的本地创建了一个文件夹:/Users/TrainingLearning/github/Python
之后执行以下命令:
echo "# python-gtts" >> README.md
git init
git add README.md
然后将我的代码(Python 文件 - TextToSpeech.py
)添加到我之前创建 README.md 文件的同一文件夹中:/Users/TrainingLearning/github/Python
并尝试做:
$ git add .
$ git commit -m "first commit"
$ git remote add origin https://github.com/rs/python-gtts.git
但是当我执行以下命令时:
$ git push -u origin master
我开始收到以下错误:
error: src refspec master does not match any.
error: failed to push some refs to 'https://github.com/rs/python-gtts.git'
解决方案
我发现了问题,我的 git 配置不正确,所以我不得不运行以下命令:
$ git config --global user.email "xxxx.xxxx@xxxxx.com" $ git config --global user.name "xxxx"
在此之后,我可以通过运行以下命令成功地将我的代码推送到 git 中:
$ git commit -m "初始提交" $ git push -u origin master
推荐阅读
- c# - 如何找出为什么特定排序较慢
- python - 尝试修改实例变量python时遇到问题
- google-cloud-logging - 在 Cloud Logging 中具有现有过滤器的同时在所有字段中搜索值
- androidpublisher - 是否有明确的 Android Publisher API 错误消息列表
- neural-network - 针对 SNR 范围训练神经网络
- javascript - 操纵动态创建的对象的值?
- python - 如何比较excel工作表名称并将其返回到列表的字典
- python - 为什么 Python 包不像 R 那样附带文档?
- python - 我无法删除出现在 DataFrame 的金额列中的日期
- c - 如何在带有链表的哈希表中修复 C 中的分段错误