{"thread":{"id":"36789","subject":"Bugreport: git push disobeys -c remote.xxx.url=...","startedAt":"2014-05-30T00:03:56Z","lastAt":"2014-05-30T01:43:59Z","messageCount":2,"participants":["fuz@fuz.su","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"242996","messageId":"20140530000356.GA8033@fuz.su","threadId":"36789","inReplyTo":null,"subject":"Bugreport: git push disobeys -c remote.xxx.url=...","fromName":"","fromEmail":"fuz@fuz.su","sentAt":"2014-05-30T00:03:56Z","receivedAt":"2014-05-30T00:03:56Z","isPatch":false,"sender":{"key":"fuz@fuz.su","avatar":null},"body":"Hello!\n\nI've tried to changing the URL of a remote temporarily because of network\nissues. I tried something like this:\n\n    git -c remote.foo.url=http://gitserver.example/repo.git push foo bar\n\nTracing shows that git push does not use the provided URL for the remote foo\nand instead uses the URL configured in the repository configuration as if the\n-c option was not present at all. This looks like a bug to me.\n\nMy git identifies as version 1.8.1.2.\n\nYours sincerely,\nRobert Clausecker\n\n-- \n()  ascii ribbon campaign - for an 8-bit clean world \n/\\  - against html email  - against proprietary attachments\n"},{"id":"242999","messageId":"20140530014359.GF28683@sigill.intra.peff.net","threadId":"36789","inReplyTo":"20140530000356.GA8033@fuz.su","subject":"Re: Bugreport: git push disobeys -c remote.xxx.url=...","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2014-05-30T01:43:59Z","receivedAt":"2014-05-30T01:43:59Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, May 30, 2014 at 02:03:56AM +0200, fuz@fuz.su wrote:\n\n> I've tried to changing the URL of a remote temporarily because of network\n> issues. I tried something like this:\n> \n>     git -c remote.foo.url=http://gitserver.example/repo.git push foo bar\n> \n> Tracing shows that git push does not use the provided URL for the remote foo\n> and instead uses the URL configured in the repository configuration as if the\n> -c option was not present at all. This looks like a bug to me.\n\nYou are correct that this won't work, but the reason is a bit\ncomplicated.\n\nThe remote.*.url config field is actually a \"multivar\", meaning that you\ncan specify it multiple times. In that case, \"git push\" will push to\neach configured URL in order in which they appear in the config.\n\nIn the command above you are not overwriting remote.foo.url, but rather\nadding an extra value to it. So we first try to push to the remote\ndefined in your actual config, and then to the one on the command-line.\nYou can see this in action like:\n\n  $ git init --bare /tmp/foo\n  $ git init --bare /tmp/bar\n  $ git remote add foo /tmp/foo\n  $ git -c remote.foo.url=/tmp/bar push foo HEAD\n\nYou should see pushes to both /tmp/foo and /tmp/bar.\n\nConfig multivars like this are rather hard to work with, as there is no\nway to say \"reset the multivar to empty, _then_ add this new value\". So\nthere isn't a simple solution using remote.*.url from the command-line\nlike this.\n\nAnother way of doing what you want is to use url.*.insteadOf, like:\n\n   git -c url./tmp/bar.insteadof=/tmp/foo push foo HEAD\n\n-Peff\n"}]}