【问题标题】:No refs in common and none specified; doing nothing没有共同的参考文献,也没有指定;什么也不做
【发布时间】:2014-06-25 01:51:29
【问题描述】:

我有一个本地 git 项目,我想将它添加到 gitolite。显然这很难,所以我放弃了这个想法。我通过将它添加到 gitolite-admin/conf/gitolite.conf 并提交和推送更改来创建一个新的 gitolite 存储库。然后我用git clone git-noah:project-name 成功克隆了新的repo。然后,我将除 .git 之外的所有文件和文件夹复制到项目名称文件夹中。我做到了,

git add -A
git commit -a -m "Moved to new repo."
git push

我收到此错误:

warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'git-noah:project-name'

【问题讨论】:

标签: git gitolite


【解决方案1】:

远程(原始)存储库中尚不存在“main”。

git push origin main

在第一次推送之后,您可以使用更简单的

git push

编辑: 随着最近的趋势,我的答案已更新为将“master”替换为“main”

【讨论】:

  • @Enrico 检查您正在推送的分支名称。随着最近的趋势,“大师”一词正在发生变化。
  • @Oliver,是的,你是对的。有些人更喜欢“master”作为“main”。
  • @Tanzeel yes 在 2020 年“主要”可能是更合适的选择。我最初的答案写于 2014 年,早于新的分支命名讨论。
  • 很奇怪,main 不起作用并给了我 refspec 错误...我不得不将其更改为 master。这是一个新的 github 仓库。
【解决方案2】:

如果你使用 git 镜像,那么使用这个:

git config remote.backup.mirror true

【讨论】:

    【解决方案3】:

    您的主分支可能位于上游,需要取消设置 在分支主机上

    您的分支基于“origin/master”,但上游已消失。 (使用git branch --unset-upstream修复)

    【讨论】:

      【解决方案4】:

      如果您收到错误:

      No refs in common and none specified; doing nothing.
      Perhaps you should specify a branch.
      

      但没有收到错误:

      warning: push.default is unset
      

      在尝试运行git push之前,请确保您已运行git commit

      【讨论】:

        【解决方案5】:

        您的本地和远程存储库不共享相同的历史记录,因为您重新创建了存储库。因此,Git 不会让你推送这些内容。

        如果不怕丢失远程仓库中的内容,可以强制推送:git push -f

        【讨论】:

        • 他们绝对分享历史!这是 git 最棒的事情之一,它知道远程仓库中发生的所有事情,因为你克隆了整个事情。
        猜你喜欢
        • 1970-01-01
        • 2017-02-13
        • 2014-09-15
        • 2018-07-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-03-26
        • 2019-11-02
        相关资源
        最近更新 更多