git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 4/4] remote.c: introduce branch.<name>.pushremote

From
Ramkumar Ramachandra <artagnon@gmail.com>
Date
Mar 18, 2013, 13:16 UTC
Message-ID
<1363612575-7340-5-git-send-email-artagnon@gmail.com>
In-Reply-To
<1363612575-7340-1-git-send-email-artagnon@gmail.com>

This new configuration variable overrides `remote.pushdefault` and `branch.<name>.remote` for pushes. In a typical triangular-workflow setup, you would want to set `remote.pushdefault` to specify the remote to push to for all branches, and use this option to override it for a specific branch.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 Documentation/config.txt | 18 ++++++++++++++----
 remote.c                 |  3 +++
 2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 8ddd0fd..d0e36e9 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -726,9 +726,18 @@ branch.<name>.remote::
 	When on branch <name>, it tells 'git fetch' and 'git push'
 	which remote to fetch from/push to.  The remote to push to
 	may be overriden with `remote.pushdefault` (for all branches).
-	If no remote is configured, or if you are not on any branch,
-	it defaults to `origin` for fetching and `remote.pushdefault`
-	for pushing.
+	The remote to push to, for the current branch, may be further
+	overriden by `branch.<name>.pushremote`.  If no remote is
+	configured, or if you are not on any branch, it defaults to
+	`origin` for fetching and `remote.pushdefault` for pushing.
+
+branch.<name>.pushremote::
+	When on branch <name>, it overrides `branch.<name>.remote`
+	when pushing.  It also overrides `remote.pushdefault` when
+	pushing from branch <name>.  In a typical triangular-workflow
+	setup, you would want to set `remote.pushdefault` to specify
+	the remote to push to for all branches, and use this option to
+	override it for a specific branch.
 
 branch.<name>.merge::
 	Defines, together with branch.<name>.remote, the upstream branch
@@ -1899,7 +1908,8 @@ receive.updateserverinfo::
 
 remote.pushdefault::
 	The remote to push to by default.  Overrides
-	`branch.<name>.remote` for all branches.
+	`branch.<name>.remote` for all branches, and is overriden by
+	`branch.<name>.pushremote` for specific branches.
 
 remote.<name>.url::
 	The URL of a remote repository.  See linkgit:git-fetch[1] or
diff --git a/remote.c b/remote.c
index 987edc4..a4d3d22 100644
--- a/remote.c
+++ b/remote.c
@@ -366,6 +366,9 @@ static int handle_config(const char *key, const char *value, void *cb)
 				default_remote_name = branch->remote_name;
 				explicit_default_remote_name = 1;
 			}
+		} else if (!strcmp(subkey, ".pushremote")) {
+			if (branch == current_branch)
+				git_config_string(&pushremote_name, key, value);
 		} else if (!strcmp(subkey, ".merge")) {
 			if (!value)
 				return config_error_nonbool(key);
-- 
1.8.2
Previous: Eric SunshineNext: Eric Sunshine
Message 11 of 16 in “Support triangular workflows”
  1. 0/4 Support triangular workflowsRamkumar Ramachandra, Mar 18, 2013
  2. 1/4 remote.c: simply a bit of code using git_config_string()Ramkumar Ramachandra, Mar 18, 2013
  3. Eric SunshineMar 18, 2013
  4. 2/4 remote.c: introduce a way to have different remotes for fetch/ pushRamkumar Ramachandra, Mar 18, 2013
  5. Jeff KingMar 18, 2013
  6. Ramkumar RamachandraMar 18, 2013
  7. Jeff KingMar 18, 2013
  8. Eric SunshineMar 18, 2013
  9. 3/4 remote.c: introduce remote.pushdefaultRamkumar Ramachandra, Mar 18, 2013
  10. Eric SunshineMar 18, 2013
  11. 4/4 remote.c: introduce branch.<name>.pushremoteRamkumar Ramachandra, Mar 18, 2013
  12. Eric SunshineMar 18, 2013
  13. Jeff KingMar 18, 2013
  14. Ramkumar RamachandraMar 18, 2013
  15. Jeff KingMar 18, 2013
  16. Marc BranchaudMar 18, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.