Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
740 views
in Technique[技术] by (71.8m points)

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

I mirrored a git repository and deleted application.properties containing passwords from the MyProject repository. I can see the message under Deleted files and my file name below:

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

Using repo : \hnas1-usersUSERSdanDesktopfg_test_after_deleteMyProject.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), ...

I have following question and problem :

I have cloned my code using git mirror from the Single_home_page repository and Since there are 4 commit-pointing refs as shown above which are HEAD, refs/heads/Single_home_page, refs/heads/Second_home_page, refs/heads/master, I want to make sure that after deleting the above file, I push my changes to Single_home_page repository only. For this, I tried doing the following:

git push origin Single_home_page and git push --set-upstream origin Single_home_page got the following error for both cases :

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

What am I doing wrong here?

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

Update on March 17th after following the steps mentioned in brian's answer:

After following the steps, I got the following :

 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.

After using + for my branch:

 $ 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)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Since you said that you mirrored the repository, what's probably going on here is that the config option remote.origin.mirror is set. You can confirm this by running git config remote.origin.mirror, which will show you true if it's set.

The easiest thing to do in this case is to run git config --unset remote.origin.mirror to turn this option off and then try your push again. Unfortunately, there isn't a useful --no-mirror option to turn this off for you.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...