我使用以下内容克隆存储库:

git clone ssh://xxxxx/xx.git 

但在我更改一些文件并添加和提交它们之后,我想将它们推送到服务器:

git add xxx.php
git commit -m "TEST"
git push origin master

但我得到的错误是:

error: src refspec master does not match any.  
error: failed to push some refs to 'ssh://xxxxx.com/project.git'

当前回答

我遇到的问题是在尝试重置存储库时。我想删除所有历史记录,什么都不做。然而,您必须至少添加一些要提交的内容,所以我只创建了一个空文本文件gitadd。然后gitcommit-m“重置存储库”。

其他回答

对于Windows上Cmder中Bash的用户,请确保在新的主目录中创建一个新的.ssh文件夹。

转到主目录cd~。生成ssh密钥ssh-keygen。保持所有输入为空(保持按回车键)将id_rsa.pub文件复制到Github>设置>SSH密钥

我遇到的问题是在尝试重置存储库时。我想删除所有历史记录,什么都不做。然而,您必须至少添加一些要提交的内容,所以我只创建了一个空文本文件gitadd。然后gitcommit-m“重置存储库”。

权限问题?解决方案:分叉

我收到这个错误是因为我没有对存储库的推送权限,所以我不得不分叉它,然后我在分叉的存储库上再次执行了pull、commit和push命令。

如果您有Visual Studio代码:

如果不需要跟踪更改,请删除.git文件夹(如果需要,请删除git stash)初始化gitcommit-m“第一次提交”git远程添加原点https://github.com/YOURusername/YOURrepo.git通过Visual Studio代码UI IDE,从左侧面板或(Ctrl+Shift+G)转到源代码控制准备所有更改或部分更改提交您的更改通过左下角按钮(如数字或云图标)同步您的更改。然后Visual Studio代码要求您输入用户名和密码。

如果您拥有存储库的权限,您可以看到:

> git push -u origin master
Fatal: AggregateException encountered.
To https://github.com/your_account/yourrepo.git
 * [new branch]      master -> master
> git status -z -u
> git symbolic-ref --short HEAD
> git rev-parse master
> git rev-parse --symbolic-full-name master@{u}
> git rev-list --left-right master...refs/remotes/origin/master
> git for-each-ref --format %(refname) %(objectname) --sort -committerdate
> git remote --verbose
> git show :ionic.config.json
> git check-ignore -z --stdin

也许GitHub不知道你是谁。

首先,您必须运行:

git config --global user.email "you@example.com"
git config --global user.name "Your Name"