【问题标题】:Git Error code: No refs in common and none specified; doing nothingGit错误代码:没有共同的参考,也没有指定;什么也不做
【发布时间】:2015-01-29 14:45:56
【问题描述】:

我正在关注 Rails 教程,但卡在第 1.4.3 章 Bitbucket 上。 https://www.railstutorial.org/book/beginning#sec-bitbucket 这是我写的,也是我得到的答案。

pellem@rails-tutorial:~/workspace/hello_app (master) $ git remote add origin git@bitbucket.org:pellemartenson/hello_app.git
fatal: remote origin already exists.

pellem@rails-tutorial:~/workspace/hello_app (master) $ git push -u origin --all                                                          
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
Everything up-to-date

我发现了一些类似的问题并尝试了一些建议。但它对我不起作用或者我不明白答案。

【问题讨论】:

  • 你试过了吗:git push -u origin master
  • 当我尝试这样做时会发生这种情况: $ git push -u origin master error: src refspec master does not match any。错误:未能将一些引用推送到 'git@bitbucket.org:pellemartenson/hello_app.git'

标签: railstutorial.org


【解决方案1】:

如果使用位桶,它会采取某些步骤是理所当然的,因此会给您带来很多痛苦。 但这是我解决这个问题的方法。 在项目的根目录中

    git init
    git add .
    git commit -m "message"

然后按照 repo 初始页面的步骤进行操作

    git remote add origin https://xxxx@bitbucket.org/xxx/xxx.git
    git push -u origin --all
    git push -u origin --tags

希望我帮助了某人!

【讨论】:

  • git commit -m "message" 应该是 git commit -m "message",破折号(-)和 m 之间没有任何空格。只是一个错字。
  • 这也帮助我在 Visual Studio 团队服务的初始设置上创建本地项目并将其推送到他们的站点。
【解决方案2】:

我想你忘了承诺。您有一个空的本地存储库。

【讨论】:

  • 哇,我花了 1 个小时来解决这个问题,你的建议是正确的——我只是忘记了 'git commit -m "initial commit"。非常感谢!
【解决方案3】:

这行得通:

git push -f -u origin master

【讨论】:

    【解决方案4】:

    你可以试试:

    git push -f -u origin master
    

    【讨论】:

    • 好的。这就是接下来发生的事情:pellem@rails-tutorial:~/workspace/hello_app (master) $ git push -f -u origin master error: src refspec master does not match any。错误:未能将一些引用推送到 'git@bitbucket.org:pellemartenson/hello_app.git' 我应该在我的 hello_app 目录中吗?没关系吗?我从来没有输入过我的密码。我不应该吗?或者当我有公钥时我不需要那个?只是一些想法。感谢所有建议!
    • git push -f 永远不应该被使用。它会破坏存储库的历史记录。提交应该是附加的,而不是破坏性的。
    • 对此没有更多想法?我被卡住了,
    • 当我从头开始重新经历所有事情时,我设法解决了这个问题。不太确定我错过了什么。
    猜你喜欢
    • 2014-06-25
    • 2017-02-13
    • 2014-09-15
    • 1970-01-01
    • 2017-09-03
    • 1970-01-01
    • 2012-09-14
    • 2018-07-04
    • 1970-01-01
    相关资源
    最近更新 更多