错误: - mirror不能与refspecs

时间:2018-03-16 16:01:58

标签: git

我镜像了一个git存储库,并从application.properties存储库中删除了包含密码的MyProject。我可以在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), ...

我有以下问题和疑问:

我已经使用来自Single_home_page存储库的git镜像克隆了我的代码。由于上面显示了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

我在这里做错了什么?

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

按照布莱恩回答中提到的步骤后,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.

+用于我的分支后:

 $ 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)

1 个答案:

答案 0 :(得分:3)

由于您说您镜像了存储库,因此可能会发生的是配置选项remote.origin.mirror已设置。您可以通过运行git config remote.origin.mirror来确认这一点,true会显示git config --unset remote.origin.mirror是否已设置。

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