本文介绍了Git错误:src refspec master与任何不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个名为碳糕的回购。



我试过这个:

将gitosis-admin存储库克隆到我的本地计算机

  $ git clone [email protected]:repositories / gitosis-admin.git 
$ cd gitosis-admin
$ vim gitosis.conf

添加了 [回购碳纤维] [group carboncake] 部分到文件结尾

  [gitosis] 

[团队]
writable = sweepshots
members = git_id_rsa

[group gitosis-admin]
writable = gitosis-admin
members = git_id_rsa

[回购碳饼]
description =由Mithun提供的全新应用程序。
owner = Mithun P

[group carboncake]
writable = myappname
members = mithun @core


$ cp /some/where/mithun.pub keydir / mithun.pub



执行以下命令:
$ $ $ $ git add gitosis.conf keydir / mithun.pub
$ git commit -m添加'carboncake'存储库和' mithun'用户。

$ git pull --rebase
$ git push

但它不会在My Server中创建任何碳蛋糕。



所以我遵循了这一点:



在服务器上执行以下命令:

  $ su gitosis 
$ git init - bare /srv/gitosis/repositories/carboncake.git

以下是我的问题:



我尝试从本地计算机检出/克隆新存储库

  $ mkdir碳糕
$ cd碳蛋糕
$ git init
$ touch a_text_file.txt
$ git add a_text_file.txt
$ git remote add origin gitosis @ myserver.net:repositories/carboncake.git
$ git push origin master

返回错误:

 错误:src refspec master与任何不匹配。 
致命:远程端意外挂起
错误:未能将一些文件推送到'[email protected]:repositories / carboncake.git'

当我尝试 git push origin HEAD:master 时,它返回错误:

 错误:src refspec HEAD与任何不匹配。 
致命:远程端意外挂起
错误:未能将一些文件推送到'[email protected]:repositories / carboncake.git'

当我尝试 git push origin master:refs / heads / master 时,它返回错误:

 错误:src refspec master与任何不匹配。 
致命:远程端意外挂起
错误:未能将一些文件推送到'[email protected]:repositories / carboncake.git'

git show-ref 在本地机器上不显示任何内容

服务器上的 /srv/gitosis/repositories/carboncake.git/refs/heads / 目录为空。



我该如何解决这个问题?

解决方案

您已经创建了一个新的存储库并添加了一些文件该索引,但你还没有创建你的第一次提交。完成之后:

  git add a_text_file.txt 
$ b

... do:

  git commit -mInitial commit 。 

...这些错误应该消失。


I need to create a repo named carboncake.

I tried this:

Cloned the gitosis-admin repository to my local machine

$ git clone [email protected]:repositories/gitosis-admin.git
$ cd gitosis-admin
$ vim gitosis.conf

Added the [repo carboncake] and [group carboncake] section to the end of the file

[gitosis]

[group team]
writable = sweepshots
members = git_id_rsa

[group gitosis-admin]
writable = gitosis-admin
members = git_id_rsa

[repo carboncake]
description = A brand new app by Mithun.
owner = Mithun P

[group carboncake]
writable = myappname
members = mithun @core

Then copied the pub key file generated by Putty (I'm using Git basg for Windows):

$cp /some/where/mithun.pub keydir/mithun.pub

Executed the following commands:

$ git add gitosis.conf keydir/mithun.pub
$ git commit -m "Added 'carboncake' repository and 'mithun' user."

$ git pull --rebase
$ git push

But it doesn't create any carboncake.git in My Server.

So I followed this:

Executed the following commands on the server:

$ su gitosis
$ git init --bare /srv/gitosis/repositories/carboncake.git

Here's my problem:

I tried to checkout/clone the new repository from my local machine

$ mkdir carboncake
$ cd carboncake
$ git init
$ touch a_text_file.txt
$ git add a_text_file.txt
$ git remote add origin [email protected]:repositories/carboncake.git
$ git push origin master

Which returned the error:

error: src refspec master does not match any.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to '[email protected]:repositories/carboncake.git'

When I tried git push origin HEAD:master it returned the error:

error: src refspec HEAD does not match any.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to '[email protected]:repositories/carboncake.git'

When I tried git push origin master:refs/heads/master it returned the error:

error: src refspec master does not match any.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to '[email protected]:repositories/carboncake.git'

git show-ref on the local machine does not display anything

Also /srv/gitosis/repositories/carboncake.git/refs/heads/ directory on the server is empty.

How can I fix this?

解决方案

You've created a new repository and added some files to the index, but you haven't created your first commit yet. After you've done:

 git add a_text_file.txt

... do:

 git commit -m "Initial commit."

... and those errors should go away.

这篇关于Git错误:src refspec master与任何不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 08:25