Git error: src refspec master does not match any. 错误处理办法

原博主地址:http://www.cnblogs.com/jeremylee/p/5715289.html

本地仓库使用如下命令初始化:

$ git init

之后使用如下命令添加远程库:

$ git remote add origin [email protected]:hahah/ftpmanage.git

然后使用

$ git push -u origin master

出现如下错误:

error: src refspec master does not match any.
error: failed to push some refs to '[email protected]:hahaha/ftpmanage.git'

原因:

本地仓库为空

解决方法:使用如下命令 添加文件;

$ git add add.php addok.php conn.php del.php edit.php editok.php ftpsql.sql index.php

$ git commit -m "init files"

之后在push过程中出现如下错误:

复制代码
$ git push -u origin master
Warning: Permanently added the RSA host key for IP address 'xx.xx.xxx.xxx' to the list of known hosts.
To [email protected]:hahaha/ftpmanage.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to '[email protected]:hahahah/ftpmanage.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 之后在 push

使用如下命令解决:

复制代码
$ git pull --rebase origin master
warning: no common commits
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From github.com:hahah/ftpmanage
 * branch            master     -> FETCH_HEAD
 * [new branch]      master     -> origin/master
First, rewinding head to replay your work on top of it...
Applying: init files
复制代码

继续push,成功。

复制代码
$ git push -u origin master
Counting objects: 10, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (10/10), done.
Writing objects: 100% (10/10), 5.15 KiB | 0 bytes/s, done.
Total 10 (delta 3), reused 0 (delta 0)
To [email protected]:hahaha/ftpmanage.git
   a2b5c30..1044f15  master -> master
Branch master set up to track remote branch master from origin.

问题二:Git 提示fatal: remote origin already exists 错误解决办法

先删除远程 Git 仓库:git remote rm origin,在执行上面的操作步骤。

问题三: 执行git push出现"Everything up-to-date"

在github上git clone一个项目,在里面创建一个目录,然后git push的时候,出现报错"Everything up-to-date"


原因:
1)没有git add .
2)没有git commit -m "提交信息"
如果上面两个步骤都成功执行,还出现这个错误是因为创建的目录下是空的,目录下必须有文件才能git push上传成功。

在github上创建文件的时候,在新文件名后加/符号就是文件夹,但是这种方式只支持英文名目录,中文名目录不支持。


将项目添加到git正确步骤:(亲试成功的,不过我是个人开发)

1、在git上创建一个项目

2、在本地新建一个文件夹,然后执行命令:

    1.git init

    2.git remote add origin https://gitee.com/TangJian211085/RectificationSystemTest.git

    3.git pull --rebase origin master

    4.将已有项目的代码复制到该新建的文件夹下

    5.git add --all

    6.git commit -m '提交描述'

    7.git push -u origin master

3. 其实可以只需在已有项目文件下执行(1、2、3、5、6、7)命令即可(同样亲试过)。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章