【问题标题】:GitHub - error: failed to push some refs to 'git@github.com:myrepo.git'GitHub - 错误: 无法将一些引用推送到 'git@github.com:myrepo.git'
【发布时间】:2012-05-31 23:14:35
【问题描述】:

我收到以下错误。我该如何解决?: 混帐添加。 git commit -m 't' git push 起源开发

To git@github.com:myrepo.git
 ! [rejected]        development -> development (non-fast-forward)
error: failed to push some refs to 'git@github.com:myrepo.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.

【问题讨论】:

    标签: github git-push


    【解决方案1】:

    您的原始存储库位于本地存储库之前。在推送之前,您需要从源存储库中提取更改,如下所示。这可以在您的提交和推送之间执行。

    git pull origin development
    

    development 指的是您要从中提取的分支。 如果你想从master 分支中提取,那么输入这个。

    git pull origin master
    

    【讨论】:

    • 上述消息中的development 指的是您要从中提取的分支。所以如果你使用master 分支,你可以输入:git pull origin master
    【解决方案2】:

    就我而言,Github 已关闭。

    也许还要检查https://www.githubstatus.com/

    您可以通过电子邮件和文本订阅通知,以了解何时可以再次推送更改。

    【讨论】:

      【解决方案3】:

      我使用了这个命令,它对我很有效:

      >git push -f origin master
      

      但请注意,这可能会删除您在远程仓库中已有的一些文件。这对我来说很方便,因为情况不同;我正在将我的本地项目推送到远程仓库,该仓库是空的,但 READ.ME

      【讨论】:

        【解决方案4】:

        我也遇到了同样的问题,解决方法如下 (如果您在本地文件夹中有项目,请按照以下步骤操作):

        1. 在guthub中创建一个新的repo
        2. 转到本地文件夹并执行“git init”
        3. git remote add origin (with your repo url) // 简单地从你的 repo 复制
        4. git add -A
        5. git commit -m "你的提交"
        6. git push -u origin master

        【讨论】:

          【解决方案5】:

          你可以在你的控制台写:

          git pull origin
          

          然后按 TAB 键并编写您的“主”存储库

          【讨论】:

            【解决方案6】:

            就我而言。我遇到了错误,因为在将 github 上的存储库创建到现有项目中后,我忘记了提交。所以我解决了:

            git add .
            git commit -m"commentary"
            

            然后我就可以打字了:

            git push -u origin master
            

            【讨论】:

              【解决方案7】:

              试试这个:

              1. git push -u origin master
              2. git push -f origin master

              有时#1 对我有用,有时#2 对我有用。我不知道它为什么会这样反应

              【讨论】:

              • -f 有效,因为它是“强制执行”
              【解决方案8】:

              我也收到了错误 ! [remote rejected] main -> main (failure) error: failed to push some refs to '<repository>'

              过来发现是这个原因:

              【讨论】:

                【解决方案9】:

                在windows中,你需要使用双引号“”。所以命令将是

                git commit -m "t"

                【讨论】:

                  【解决方案10】:

                  在我的情况下,git push 试图推送更多内容,而不是当前分支,因此,由于其他分支不同步,我收到此错误。

                  要解决这个问题,您可以使用:git config --global push.default simple 这将使 git 只推送当前分支。

                  这仅适用于较新版本的 git。即:不适用于 1.7.9.5

                  【讨论】:

                    【解决方案11】:

                    这个命令对我有用:

                    git push --set-upstream origin master
                    

                    如果它不起作用,请确保您正在推送您所在的当前分支。

                    App University>git branch
                    * master
                      test
                    

                    然后,您必须将代码推送到主分支上

                     App University>git push origin master
                    

                    【讨论】:

                      【解决方案12】:

                      我遇到了以下错误 $ git push origin main 错误:src refspec main 不匹配任何 错误:无法将一些引用推送到“https://github.com/--------/git-init-sample.git”

                      解决方案:我没有连接到 git local repo https://github.com/login/oauth/authorize?response_type=

                      一旦我连接错误就消失了

                      $ git push origin main 枚举对象:3,完成。 计数对象:100% (3/3),完成。

                      【讨论】:

                      • 格式缺失
                      【解决方案13】:
                      $ git fetch --unshallow origin
                      $ git push you remote name
                      

                      【讨论】:

                        猜你喜欢
                        • 2020-03-04
                        • 2014-07-29
                        • 1970-01-01
                        • 2019-07-29
                        • 2011-11-24
                        • 2023-03-16
                        • 2017-11-27
                        • 2012-06-21
                        • 1970-01-01
                        相关资源
                        最近更新 更多