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

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'

当前回答

试试看:

git add .

git commit -m "your commit message"

git remote add origin *remote repository URL*

git push origin *your-branch-name*

其他回答

在我Git只添加了一个目录之后,我发现这发生在一个全新的存储库中。

一旦我添加了一个文件(例如README),Git推送就非常成功。

当您添加了文件,忘记提交和推送时,就会发生这种情况。所以提交文件,然后推送。

对我来说,只需签出我希望代码推送的分支,然后简单地推送您的代码。

git checkout -b branchname-on-which-i-will-push-my-code

git add .
git commit -m "my commit message"
git push origin branchname-on-which-i-will-push-my-code

我也犯了类似的错误。但Git告诉我:

*** Please tell me who you are.

Run

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

或设置帐户的默认身份。

Omit --global to set the identity only in this repository.

然后错误消失。

如果您有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