Reputation: 14847
I'm trying to keep in sync two repository hosted in two different sites (Github and Bitbucket) following a guide i added a new origin url to the config and now my .git/config looks like this:
[remote "origin"]
url = https://[email protected]/rrev/sampclient.git
fetch = +refs/heads/*:refs/remotes/origin/*
url = https://github.com/rrev/SAMPClient.git
Now Github and Bitbucket have the same commits and the same source code but when i try to push a commit to the two repositories Visual Studio sends the commit only to Github leaving the Bitbucket behind.
It looks like Visual Studio doesn't work well with two urls because, when i moved url = https://github.com/rrev/SAMPClient.git
in [remote "all"]
for testing, Visual Studio sends correctly the commit to Bitbucket and when i put back the Github url it detected that the repository was behind the local repository.
It's a limitation of Visual Studio? Because when i use the command line to push the changes (using git push
) the two repositories gets synced correctly.
Upvotes: 1
Views: 124
Reputation: 164809
If you need two remotes, you need two remotes. I'm totally wrong, git push
will honor multiple URLs. I can't tell if this is a deliberate or accidental feature. According to libgit2 this is a deliberate feature of Git for exactly your situation.
My guess is that Visual Studio is not using the git command line but is instead using a library such as libgit2 (confirmed). libgit2 is a much faster and more reliable option (especially on Windows) for an application to use Git than by wrapping the command line. libgit2 does not have direct analogies to the Git command line, working with remotes is particularly involved. libgit2 remotes can only have one url, it's baked into their data structure and API.
My suggestion is to either push from the command line, or two have two remotes and remember to push to both of them, or decide one of them is a mirror and set up an automatic process to sync it, or (IMO best) decide you don't need to maintain an identical repository on a redundant development service.
Upvotes: 1
Reputation: 37
This is a limitation of Visual Studio. How you can see if using git push
all working good.
-Anton Ego
Upvotes: 1