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

作者:佚名 上传时间:2019-05-13 版权申诉

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

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

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

免责申明:文章和图片全部来源于公开网络,如有侵权,请通知删除 server@dude6.com

用户评论
相关推荐
error: src refspec master does not match any.
添加远程仓库出现如下问题: error: src refspec master does not match any.error: failed to push some refs
Git__02_error: src refspec master does not match any
现象:在一个目录下初始化仓库之后,就开始push到github,结果出现了这个错误。 错因:初始化仓库之后,并没有使用git add,git commit 命令将文件添加
Git提交时出现error: src refspec master does not match any
在Git中,当出现error: src refspec master does not match any错误时,这通常表示当前分支没有可提交的内容。这可能是因为你的本地仓库中没有任何提交记录,或者你
Git 2.x
Git
2023-12-11 06:45
Git::error:src refspec master does not match any
新建立了一个远程仓库,想着把项目放上去。于是在项目目录上: git init 然后就添加远程库 git remote add origin xxxx.gi
Git提交时出现error: src refspec master does not match any怎么解决?
这个错误通常出现在你尝试推送到一个不存在的分支时。这可能是因为你的本地仓库还没有提交任何内容,或者你想要推送的分支名称不正确。要解决这个问题,首先确保你已经在本地进行了提交。使用git status命
Git 2.x
Git
2023-11-25 22:22
Git提交时出现'error: src refspec master does not match any'怎么解决?
这个错误通常表示当前分支没有可推送的更改。解决这个问题的方法有两种。第一种是确保当前分支有提交记录,并且你处于正确的分支上。可以通过以下步骤解决:首先,确保你在正确的分支上。可以使用命令 git
Git 2.x
Git
2023-12-11 03:13
Git无法推送到远程仓库,报error: src refspec master does not match any
这个错误通常出现是因为本地仓库没有与远程仓库建立关联或者当前分支没有任何提交。解决这个问题的步骤如下:首先确保你已经在本地仓库目录中,并且执行 git status 命令,确认是否有未提交的更改
Git 2.0及以上
Git
2023-11-29 18:43
Git提交时出现error: src refspec main does not match any
这个错误通常是因为本地的main分支没有与远程仓库的main分支关联导致的。要解决这个问题,首先确保你的本地main分支存在并有内容。然后,执行以下命令:git branch -M main
Git 2.x
Git
2023-11-16 12:39
Git无法提交更改,出现'error: src refspec main does not match any'
在使用Git提交更改时,出现'error: src refspec main does not match any'错误通常是因为当前分支没有与远程仓库关联或者本地仓库为空。要解决这个问题,首先确保当
Git 2.0及以上
Git
2023-11-13 17:51
Git提交时出现'error: src refspec main does not match any'怎么解决?
提交时出现 'error: src refspec main does not match any' 错误通常是由于本地仓库的分支与远程仓库的分支不匹配引起的。这个问题的解决方法有两种,你可以选择其中
Git 2.x
Git
2023-12-09 01:37