If the current local branch's name differs from the remote's branch
name then using the local branch name as an explicit refspec will
cause git to create a new branch in the remote repository. magit
itself does not parse the "remote.<remotename>.push" config option. By
leaving out the refspec from the push command git will parse that
config option itself and push to the correct branch in the remote
repository.

If 'magit-push' is called with a prefix or if no remote has been
configured for the current local branch then the local branch name
will still be used as an explicit refspec.
---
 magit.el |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/magit.el b/magit.el
index af15e0f..b20884c 100644
--- a/magit.el
+++ b/magit.el
@@ -2598,15 +2598,19 @@ branch."
   (let* ((branch (or (magit-get-current-branch)
                     (error "Don't push a detached head. That's gross.")))
         (branch-remote (magit-get "branch" branch "remote"))
-        (push-remote (if (or current-prefix-arg
-                             (not branch-remote))
+        (explicit-remote-branch (or current-prefix-arg
+                                    (not branch-remote)))
+        (push-remote (if explicit-remote-branch
                          (magit-read-remote (format "Push %s to" branch)
                                             branch-remote)
-                       branch-remote)))
+                       branch-remote))
+        (args (list "push" "-v" push-remote)))
+    (if explicit-remote-branch
+       (nconc args (list branch)))
     (if (and (not branch-remote)
             (not current-prefix-arg))
        (magit-set push-remote "branch" branch "remote"))
-    (magit-run-git-async "push" "-v" push-remote branch)))
+    (apply 'magit-run-git-async args)))
 
 ;;; Log edit mode
 
-- 
1.6.3.3

To unsubscribe from this group, send email to magit+unsubscribegooglegroups.com 
or reply to this email with the words "REMOVE ME" as the subject.

Reply via email to