error: src refspec master does not match any. 错误

简介:

添加远程仓库出现如下问题:

error: src refspec master does not match any.
error: failed to push some refs to 'https://github.com/liyihang/CorePython.git'

出现这个问题是因为本地仓库为空,我们只要在本地仓库中tianji

添加相关的文件即可。然后执行

git add -A

接着提交,

H:\Python_demo\CorePythonApplicationProgramming>git commit -m "chapter1"
[master (root-commit) 4c820d9] chapter1
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 chapter1/a.txt

之后执行,

git push -u origin master

执行后出现如下错误;

H:\Python_demo\CorePythonApplicationProgramming>git push -u origin master
To github.com:liyihang/CorePython.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'git@github.com:liyihang/CorePython.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

上面提示我们需要执行

git pull

我们只需要执行

H:\Python_demo\CorePythonApplicationProgramming>git pull --rebase origin master
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
warning: no common commits
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From github.com:liyihang/CorePython
 * branch            master     -> FETCH_HEAD
 * [new branch]      master     -> origin/master
First, rewinding head to replay your work on top of it...
Applying: chapter1

最后执行下面git push命令即可;

H:\Python_demo\CorePythonApplicationProgramming>git push -u origin master
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (4/4), 319 bytes | 0 bytes/s, done.
Total 4 (delta 0), reused 0 (delta 0)
Branch master set up to track remote branch master from origin.
To github.com:liyihang/CorePython.git
   1cd7481..c6ba515  master -> master

最后即可以添加远程仓库。

目录
相关文章
|
JavaScript 前端开发
vue 实现word文档预览和下载
vue 实现word文档预览和下载
2144 0
|
缓存 JSON JavaScript
鸿蒙开发实现图片上传(上传用户头像)
本内容介绍了一种基于HarmonyOS的应用场景,主要实现图片选择、拷贝到缓存目录以及上传的功能。首先通过系统文件选择器(FilePicker)选择图片,无需额外权限;接着使用`fs`模块将选中的图片复制到应用缓存目录(cacheDir),以满足上传功能的路径要求;最后利用`request.uploadFile`方法将图片上传至服务器,并处理响应结果。代码详细展示了每个步骤的实现逻辑,包括图片选择、文件操作和网络请求,适用于需要实现图片上传功能的开发者。
1403 13
|
开发工具 git
解决git push时的错误提示:“error: src refspec master does not match any”
8 .如果确认以上都无误但依然出现该提示,则可能需要重新设置跟踪上游(upstream),通过如下命令:
5522 8
|
存储 关系型数据库 MySQL
使用命令行cmd查询MySQL表结构信息技巧分享。
掌握了这些命令和技巧,您就能快速并有效地从命令行中查询MySQL表的结构信息,进而支持数据库维护、架构审查和优化等工作。
1140 9
|
网络安全 开发工具 git
git修改提交路径以及强制提交——异常:error: remote origin already exists.与异常:error: failed to push some refs to的解决
git修改提交路径以及强制提交——异常:error: remote origin already exists.与异常:error: failed to push some refs to的解决
1144 0
|
存储 Unix Linux
操作系统和内核有什么区别?
操作系统和内核有什么区别?
2996 0
操作系统和内核有什么区别?
|
数据可视化 API 数据处理
【Python篇】matplotlib超详细教程-由入门到精通(上篇)
【Python篇】matplotlib超详细教程-由入门到精通(上篇)
1536 5
|
Ubuntu Linux
在Linux中,如何配置静态和动态IP地址?
在Linux中,如何配置静态和动态IP地址?
|
Java API
如何在 Java 中将 Arraylist 变成数组?
【8月更文挑战第23天】
1154 0
|
Java Python
pycharm-ieda-phpstorm超级好用插件,一键解释代码
pycharm-ieda-phpstorm超级好用插件,一键解释代码