错误:--mirror 不能与 refspecs 结合使用

Dan*_*Dan 5 git

我镜像了一个 git 存储库并application.propertiesMyProject存储库中删除了包含密码的内容。我可以看到下面的消息Deleted files和我的文件名:

$ java -jar bfg-1.13.0.jar --delete-files application.properties --no-blob-protection MyProject.git

Using repo : \\hnas1-users\USERS\dan\Desktop\bfg_test_after_delete\MyProject.git

Found 0 objects to protect
Found 4 commit-pointing refs : HEAD, refs/heads/Single_home_page, refs/heads/Second_home_page, refs/heads/master

Protected commits
-----------------
You're not protecting any commits, which means the BFG will modify the contents of even *current* commits.
This isn't recommended - ideally, if your current commits are dirty, you should fix up your working copy and commit that, check that your build still works, and only then run the BFG to clean up your history.

Cleaning
--------

Found 862 commits
Cleaning commits:       100% (862/862)
Cleaning commits completed in 99,796 ms.

Updating 3 Refs
---------------

        Ref                             Before     After
        ---------------------------------------------------
        refs/heads/Single_home_page   | 7e099f8c | d4fa8bdc
        refs/heads/Second_home_page | 0145da48 | 1b9b1ca2
        refs/heads/master             | 0e8ac08e | 502363b0

Updating references:    100% (3/3)
...Ref update completed in 393 ms.

Commit Tree-Dirt History
------------------------

        Earliest                                              Latest
        |                                                          |
        DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD

        D = dirty commits (file tree fixed)
        m = modified commits (commit message or parents changed)
        . = clean commits (no changes to file tree)

                                Before     After
        -------------------------------------------
        First modified commit | 5a303ff3 | 0280ae15
        Last dirty commit     | 7e099f8c | d4fa8bdc

Deleted files
-------------

        Filename                 Git id
        -----------------------------------------------------------------
        application.properties | c5e94e15 (2.3 KB), b8f324fd (887 B), ...
Run Code Online (Sandbox Code Playgroud)

我有以下问题和问题:

我已经使用Single_home_page存储库中的git mirror 克隆了我的代码,并且由于有 4 个指向提交的引用,如上所示HEAD, refs/heads/Single_home_page, refs/heads/Second_home_page, refs/heads/master,我想确保在删除上述文件后,我只将更改推送到Single_home_page存储库。为此,我尝试执行以下操作:

git push origin Single_home_pagegit push --set-upstream origin Single_home_page 在两种情况下都出现以下错误:

error: --mirror can't be combined with refspecs

我在这里做错了什么?

================================================== ====================

按照 brian 回答中提到的步骤,于 3 月 17 日更新:

按照步骤操作后,我得到以下信息:

 git push origin Single_home_page
To http://<path to git repo>/MyProject.git
 ! [rejected]        Single_home_page -> Single_home_page (non-fast-forward)
error: failed to push some refs to 'http://<path to git repo>/MyProject.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Run Code Online (Sandbox Code Playgroud)

使用后,+对我的分支:

 $ git push origin +Single_home_page
Counting objects: 10089, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (4439/4439), done.
Writing objects: 100% (10089/10089), 32.84 MiB | 6.27 MiB/s, done.
Total 10089 (delta 5475), reused 6793 (delta 4329)
To http://<path to MyProject>/MyProject.git
 + 7e099f8...d4fa8bd Single_home_page -> Single_home_page (forced update)
Run Code Online (Sandbox Code Playgroud)

bk2*_*204 17

既然你说你镜像了存储库,那么这里可能发生的remote.origin.mirror是设置了 config 选项。您可以通过运行来确认这一点git config remote.origin.mirror,它会告诉您true是否已设置。

在这种情况下,最简单的方法是运行git config --unset remote.origin.mirror以关闭此选项,然后再次尝试推送。不幸的是,没有一个有用的--no-mirror选项可以为您关闭此功能。