我试图按照this帖子中建议的解决方案,但它没有工作,我仍然得到:src refspec master不匹配任何。
这是我做的:跟随this解决方案
// adding the file I created
$ git add .
$ git commit -m 'initial commit'
$ git push origin master
error: src refspec master does not match any.
做的时候:
$ git push origin HEAD:master
b40ffdf..a0d1423 HEAD -> master // looks promising
// adding a remote
$ git remote add devstage -f <another git>
$ git merge devstage/master -s recursive -X ours
$ git push -u devstage master
error: src refspec master does not match any.
更多信息:
$ git branch
* origin
$ git show-ref
refs/heads/origin
refs/remotes/devstage/master
refs/remotes/origin/HEAD
refs/remotes/origin/devstage
refs/remotes/origin/master
refs/remotes/origin/origin
所以我肯定缺少refs / heads / master但不知道如何创建它。
谢谢
从git branch
看来,你的本地分支名称似乎是“起源”。
您可以使用-mv
标志重命名分支,如下所示:
git branch -mv origin master
在此之后git branch
应该显示master
:-)
只是为了确保名称确实是唯一误入歧途的东西,你可以运行git log
并查看最后几个提交 - 并将它们与bitbucket网站上的最后几个提交进行比较。
运行命令git show-ref
,结果refs/heads/YOURBRANCHNAME
如果你的分支不存在,那么你需要切换分支
git checkout -b "YOURBRANCHNAME"
git show-ref
,现在将显示您的分支参考。
现在,您可以在分支上执行操作。
当分支名称中有拼写错误时,通常会发生此错误。
例如,你在分支adminstration
,你想调用:git push origin administration
。
请注意,你在没有第二个i
字母的分支上:admin(i)stration
,这就是为什么git会阻止你推送到另一个分支!
在git config中设置用户名和密码
在终端中,键入
vi .git/config
编辑网址
url = https://username:[email protected]/username/repo.git
输入:wq
来保存
只是因为您的本地分支不计算远程存储库中的那个。 git push origin HEAD:master让你忽略冲突并上传你的提交。
对于新的存储库,该方法适用于我:
rm -rf .git
git add . && git commit -m "your commit"
git remote add origin <your git URL>
git push -u origin master -f
因为它是一个新的存储库,所以删除git并再次添加它并不重要。
它发生在我身上,我发现github试图验证我的帐户。所以你需要这两个命令:
git config --global user.email <your github email>
git config --global user.name <your github username>
对我来说,修复似乎是“git”。 (分段所有当前文件)。显然这是在git init之后需要的吗?我跟着它“get reset”(取消暂停所有文件)并继续执行完全相同的命令,只播放几个文件,然后成功推送。
git .
git reset
错误演示:
007@WIN10-711082301 MINGW64 /d/1 (dev)
$ git add --all
007@WIN10-711082301 MINGW64 /d/1 (dev)
$ git status
On branch dev
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: index.html
new file: photo.jpg
new file: style.css
007@WIN10-711082301 MINGW64 /d/1 (dev)
$ git push origin dev
error: src refspec dev does not match any.
error: failed to push some refs to '[email protected]:yourRepo.git'
你可能不会做$ git commit -m "discription"
。
解:
007@WIN10-711082301 MINGW64 /d/1 (dev)
$ git commit -m "discription"
[dev (root-commit) 0950617] discription
3 files changed, 148 insertions(+)
create mode 100644 index.html
create mode 100644 photo.jpg
create mode 100644 style.css
007@WIN10-711082301 MINGW64 /d/1 (dev)
$ git push origin dev
To [email protected]:Tom007Cheung/Rookie-s-Resume.git
! [rejected] dev -> dev (fetch first)
error: failed to push some refs to '[email protected]:yourRepo.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 init
git add .
git commit -m 'Initial Commit'
git push -u origin master
我有同样的问题,要解决它,请按照这些步骤
git init
git add .
git commit -m 'message'
git push -u origin master
在此之后,如果仍有该错误,请再次执行以下步骤
git add .
git commit -m 'message'
git push -u origin master
这对我有用,希望它会帮助任何人
我再次出现相同的错误。
我在本地存储库中添加了文件并尝试了该命令
“git push origin master”
显示相同的错误
所有我都不在乎我没有承诺。
“git commit -m'message'”
运行后,它工作
试着做 :
git push origin HEAD:master
只需添加一个空提交就可以解决问题
$ git commit -m "empty commit" --allow-empty
$ git push
//上面make empty commit而不编辑然后push
git push origin HEAD:master
当我尝试简单地使用git push
时,Git抛出了以下错误。很明显这是因为Git在推送提交时匹配本地和远程分支。这是push.default
行为,你可以找到更多细节here.
fatal: The upstream branch of your current branch does not match
the name of your current branch. To push to the upstream branch
on the remote, use
git push origin HEAD:<Branch_Name>
To push to the branch of the same name on the remote, use
git push origin <Branch_Name>
To choose either option permanently, see push.default in 'git help config'.
检查是否从所需目录(放置文件的位置)调用git命令。
在我的情况下,错误是因为我正在打字造成的
git push origin master
当我在开发分支时尝试:
git push origin branchname
希望这有助于某人