Git Tip: git push ‘No refs in common and none specified’

Git推送错误解决:源空仓库与本地仓库不匹配问题
本文详细介绍了在从Subversion切换到Git后遇到的一个常见问题,即尝试将本地仓库推送到一个为空的远程仓库时出现的错误。解释了原因在于两个仓库文件内容不匹配,并提供了简单的解决方案来修复问题。
源:http://blog.youkuaiyun.com/fudesign2008/article/details/8692696
评:


@see http://www.thebuzzmedia.com/git-tip-git-push-no-refs-in-common-and-none-specified/


Git is a source-control tool used by software developers.

I recently switched from Subversion to Git and while things have been mostly smooth, there have been a few “WTF?” moments. I am going to try and blog the few beginner ones I ran into in hopes of helping anyone else.

Today I ran a ‘git push’ to shove my commits from my local repository back into the main remote repo, the result was this:

$ git push
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
error: failed to push some refs to 'git@github.com:painfreepr/<repo>.git'

The odd bit is that I had just done this with a previous repo about 30 mins ago and it worked fine; this was a new repository I was setting up. As it turns out this is the result of originally cloning an empty repository (link, link) which is exactly what I did. I had created a new repo on GitHub and wanted to pull the repo down in IntelliJ to then add some files to it via the GUI instead of from the command line; so I had checked out the empty repo right after creating it.

The fix, fortunately, is dead easy:

$ git push origin master

Doing this should provide output like:

$ git push origin master

Counting objects: 568, done.

Delta compression using up to 2 threads.

Compressing objects: 100% (559/559), done.

Writing objects: 100% (568/568), 2.28 MiB | 2.18 MiB/s, done.

Total 568 (delta 205), reused 0 (delta 0)

To git@github.com:painfreepr/<repo>.git

* [new branch] master -> master

It is my understanding that the core issue is that there are no files in commonbetween the original remote repo you cloned (empty) and the one on-disk (now full of files). Doing the git-push-origin-master shoves your repo up into the empty repository and gives you that common base again so you can do a ‘git push‘ without issue.

Happy Git’ing!
Started by user zhaoshihao Running as SYSTEM Building in workspace C:\ProgramData\Jenkins\.jenkins\workspace\jj The recommended git tool is: NONE No credentials specified > git.exe rev-parse --resolve-git-dir C:\ProgramData\Jenkins\.jenkins\workspace\jj\.git # timeout=10 Fetching changes from the remote Git repository > git.exe config remote.origin.url git@gitee.com:qwerrain/jx.git # timeout=10 Fetching upstream changes from git@gitee.com:qwerrain/jx.git > git.exe --version # timeout=10 > git --version # 'git version 2.49.0.windows.1' > git.exe fetch --tags --force --progress -- git@gitee.com:qwerrain/jx.git +refs/heads/*:refs/remotes/origin/* # timeout=10 ERROR: Error fetching remote repo 'origin' hudson.plugins.git.GitException: Failed to fetch from git@gitee.com:qwerrain/jx.git at PluginClassLoader for git//hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:999) at PluginClassLoader for git//hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1240) at PluginClassLoader for git//hudson.plugins.git.GitSCM._checkout(GitSCM.java:1311) at PluginClassLoader for git//hudson.plugins.git.GitSCM.checkout(GitSCM.java:1278) at hudson.scm.SCM.checkout(SCM.java:540) at hudson.model.AbstractProject.checkout(AbstractProject.java:1250) at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:649) at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:85) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:522) at hudson.model.Run.execute(Run.java:1833) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44) at hudson.model.ResourceController.execute(ResourceController.java:101) at hudson.model.Executor.run(Executor.java:446) Caused by: hudson.plugins.git.GitException: Command "git.exe fetch --tags --force --progress -- git@gitee.com:qwerrain/jx.git +refs/heads/*:refs/remotes/origin/*" returned status code 128: stdout: stderr: Host key verification failed. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2852) at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2188) at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:638) at PluginClassLoader for git//hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:997) ... 12 more ERROR: Error fetching remote repo 'origin' Finished: FAILURE
10-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值