【git】error: src refspec master does not match any.

时间:2021-05-13 16:26:21

之前搭建了自己的本地的git服务器: http://blog.csdn.net/commshare/article/details/18368695

今天有新的工程要加入。


创建远程的git工程,并push 代码进去的过程如下:

参考 http://my.oschina.net/psuyun/blog/123005

a git服务器使用如下命令新建一个项目

1 cd /opt/git
2 mkdir project.git
3 cd project.git
4 $ git --bare init
b 客户端clone代码并提交
1 cd myproject
2 $ git init
3 $ git add .
4 $ git commit -m 'initial commit'
5 $ git remote add origin git@gitserver:/opt/git/project.git
6 $ git push origin master

add文件之后,remote 源加入,然后直接push:

root@Ubuntu32:/home/zhangbin/streaming/live/android-streamer-BACKUP/testMemoryBuffer# git push origin master
error: src refspec master does not match any.
error: failed to push some refs to 'file:///home/zhangbin/alex/gitProject/meTestLocalBufferQueue.git'



root@Ubuntu32:/home/zhangbin/streaming/live/android-streamer-BACKUP/testMemoryBuffer# git remote add origin file:///home/zhangbin/alex/gitProject/meTestLocalBufferQueue.git
fatal: remote origin already exists.
root@Ubuntu32:/home/zhangbin/streaming/live/android-streamer-BACKUP/testMemoryBuffer# 
root@Ubuntu32:/home/zhangbin/streaming/live/android-streamer-BACKUP/testMemoryBuffer# 
root@Ubuntu32:/home/zhangbin/streaming/live/android-streamer-BACKUP/testMemoryBuffer# git push origin mastererror: src refspec master does not match any.
error: failed to push some refs to 'file:///home/zhangbin/alex/gitProject/meTestLocalBufferQueue.git'
root@Ubuntu32:/home/zhangbin/streaming/live/android-streamer-BACKUP/testMemoryBuffer# git push origin master
error: src refspec master does not match any.
error: failed to push some refs to 'file:///home/zhangbin/alex/gitProject/meTestLocalBufferQueue.git'
root@Ubuntu32:/home/zhangbin/streaming/live/android-streamer-BACKUP/testMemoryBuffer# git push origin master
error: src refspec master does not match any.
error: failed to push some refs to 'file:///home/zhangbin/alex/gitProject/meTestLocalBufferQueue.git'
root@Ubuntu32:/home/zhangbin/streaming/live/android-streamer-BACKUP/testMemoryBuffer# 
root@Ubuntu32:/home/zhangbin/streaming/live/android-streamer-BACKUP/testMemoryBuffer# 
root@Ubuntu32:/home/zhangbin/streaming/live/android-streamer-BACKUP/testMemoryBuffer# LS
The program 'LS' is currently not installed.  You can install it by typing:
apt-get install sl
root@Ubuntu32:/home/zhangbin/streaming/live/android-streamer-BACKUP/testMemoryBuffer# ls
depFFmpegX86.sh  main.o     Makefile_test  me_config_q.h    me_pkt_dumper.d  me_queue.c  me_queue.o        wild.mp4
main.c           Makefile   me_config_q.c  me_config_q.o    me_pkt_dumper.h  me_queue.d  testMemoryBuffer
main.d           Makefile~  me_config_q.d  me_pkt_dumper.c  me_pkt_dumper.o  me_queue.h  Untitled Folder
root@Ubuntu32:/home/zhangbin/streaming/live/android-streamer-BACKUP/testMemoryBuffer# touch READEM.md
root@Ubuntu32:/home/zhangbin/streaming/live/android-streamer-BACKUP/testMemoryBuffer# gedit READEM.md 

root@Ubuntu32:/home/zhangbin/streaming/live/android-streamer-BACKUP/testMemoryBuffer# git add READEM.md


原因在于没有commit就push了


root@Ubuntu32:/home/zhangbin/streaming/live/android-streamer-BACKUP/testMemoryBuffer# git commit -m "initial commit"
[master (root-commit) 7715c2b] initial commit
 23 files changed, 2901 insertions(+)
 create mode 100644 Makefile
 create mode 100644 Makefile_test
 create mode 100644 Makefile~
 create mode 100644 READEM.md
 create mode 100755 Untitled Folder/mePktDumper2BUFFER.c
 create mode 100644 depFFmpegX86.sh
 create mode 100755 main.c
 create mode 100644 main.d
 create mode 100644 main.o
 create mode 100755 me_config_q.c
 create mode 100644 me_config_q.d
 create mode 100755 me_config_q.h
 create mode 100644 me_config_q.o
 create mode 100755 me_pkt_dumper.c
 create mode 100644 me_pkt_dumper.d
 create mode 100755 me_pkt_dumper.h
 create mode 100644 me_pkt_dumper.o
 create mode 100755 me_queue.c
 create mode 100644 me_queue.d
 create mode 100755 me_queue.h
 create mode 100644 me_queue.o
 create mode 100755 testMemoryBuffer
 create mode 100755 wild.mp4
root@Ubuntu32:/home/zhangbin/streaming/live/android-streamer-BACKUP/testMemoryBuffer# git push origin master
Counting objects: 26, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (25/25), done.
Writing objects: 100% (26/26), 1.56 MiB | 0 bytes/s, done.
Total 26 (delta 7), reused 0 (delta 0)
To file:///home/zhangbin/alex/gitProject/meTestLocalBufferQueue.git
 * [new branch]      master -> master
root@Ubuntu32:/home/zhangbin/streaming/live/android-streamer-BACKUP/testMemoryBuffer# 



为毛gitweb看不到内容,是没有放进去么?


git clone file:///home/zhangbin/alex/gitProject/meTestLocalBufferQueue.git
Cloning into 'meTestLocalBufferQueue'...
remote: Counting objects: 26, done.
remote: Compressing objects: 100% (25/25), done.
remote: Total 26 (delta 7), reused 0 (delta 0)
Receiving objects: 100% (26/26), 1.56 MiB | 0 bytes/s, done.
Resolving deltas: 100% (7/7), done.
Checking connectivity... done.