Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

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-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), ...

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)
like image 648
Dan Avatar asked Mar 16 '18 16:03

Dan


1 Answers

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.

like image 143
bk2204 Avatar answered Oct 18 '22 04:10

bk2204