-4

I have a git repository which I am pushing changes to remote X. Now, I created another git remote (different repository), and I want to push my changes to it as well. Ideally, I would like to keep to two sync. By making changes in one and pushing to the other.

I added the new remote to my git. I made a commit and pushed all changes to one repository (origin) However when I try to push the changes:

git push my-new-remote-origin my_current_branch:master

I get this error :

error: src refspec my_current_branch does not match any
error: failed to push some refs to <NEW_GIT_REPO_ADDRESS>

Is my solution correct? Why is it failing (should I specify the commit to push?)

matt
  • 515,959
  • 87
  • 875
  • 1,141
MasterOfPuppets
  • 173
  • 3
  • 10
  • 1
    Or more likley [Message 'src refspec master does not match any' when pushing commits in Git](https://stackoverflow.com/questions/4181861/message-src-refspec-master-does-not-match-any-when-pushing-commits-in-git) – Liam Aug 17 '20 at 13:01
  • Looked at both it doesn't solve my problem. – MasterOfPuppets Aug 17 '20 at 13:04
  • 2
    Ok well your going to need to provide us with a [mcve] then – Liam Aug 17 '20 at 13:07

1 Answers1

0

You should use --mirror. This will sync your new reposoitory.

Instead of naming each ref to push, specifies that all refs under refs/ (which includes but is not limited to refs/heads/, refs/remotes/, and refs/tags/) be mirrored to the remote repository. Newly created local refs will be pushed to the remote end, locally updated refs will be force updated on the remote end, and deleted refs will be removed from the remote end. This is the default if the configuration option remote..mirror is set.

Use the following command:

git push --mirror my-new-remote-origin

Documentation found here.

steadweb
  • 15,364
  • 3
  • 33
  • 47