Even more control for pushing.
* magit.el (magit-push): Always push the current branch and nothing else. Ask for a remote when none is configured yet and set it. Also ask when given a prefix argument, but don't set it as default in that case. * magit.texi (Pushing and Pulling): Document this.
This commit is contained in:
parent
a96b8763b5
commit
157bee4bf5
2 changed files with 26 additions and 20 deletions
23
magit.el
23
magit.el
|
@ -1716,20 +1716,27 @@ Please see the manual for a complete description of Magit.
|
|||
(interactive)
|
||||
(magit-run-async "git" "pull" "-v"))
|
||||
|
||||
(defun magit-read-remote (prompt)
|
||||
(completing-read prompt
|
||||
(defun magit-read-remote (prompt def)
|
||||
(completing-read (if def
|
||||
(format "%s (default %s): " prompt def)
|
||||
(format "%s: " prompt))
|
||||
(magit-shell-lines "git remote")
|
||||
nil nil nil nil nil))
|
||||
nil nil nil nil def))
|
||||
|
||||
(defun magit-push ()
|
||||
(interactive)
|
||||
(let* ((branch (or (magit-get-current-branch)
|
||||
(error "Don't push a detached head. That's gross.")))
|
||||
(remote (and current-prefix-arg
|
||||
(magit-read-remote "Push to: "))))
|
||||
(if remote
|
||||
(magit-run-async "git" "push" "-v" remote)
|
||||
(magit-run-async "git" "push" "-v"))))
|
||||
(branch-remote (magit-get "branch" branch "remote"))
|
||||
(push-remote (if (or current-prefix-arg
|
||||
(not branch-remote))
|
||||
(magit-read-remote (format "Push %s to" branch)
|
||||
branch-remote)
|
||||
branch-remote)))
|
||||
(if (and (not branch-remote)
|
||||
(not current-prefix-arg))
|
||||
(magit-set push-remote "branch" branch "remote"))
|
||||
(magit-run-async "git" "push" "-v" push-remote branch)))
|
||||
|
||||
;;; Log edit mode
|
||||
|
||||
|
|
23
magit.texi
23
magit.texi
|
@ -36,6 +36,7 @@ as an extension to Emacs.
|
|||
* History::
|
||||
* Reflogs::
|
||||
* Diffing::
|
||||
* Tagging::
|
||||
* Resetting::
|
||||
* Branching::
|
||||
* Merging::
|
||||
|
@ -438,21 +439,19 @@ it, like from any other diff.
|
|||
@node Pushing and Pulling
|
||||
@chapter Pushing and Pulling
|
||||
|
||||
Magit will run @code{git push} when you type @kbd{P}. You can type
|
||||
@kbd{$} to pop up a buffer with the transcript of running these
|
||||
commands.
|
||||
Magit will run @code{git push} when you type @kbd{P}. If you give a
|
||||
prefix argument to @kbd{P}, you will be prompted for the repository to
|
||||
push to. When no default remote repositor has been configured yet for
|
||||
the current branch, you will be prompted as well. Typing @kbd{P} will
|
||||
only push the current branch to the remote. In other words, it will
|
||||
run @code{git push <remote> <branch>}.
|
||||
|
||||
Typing @kbd{f} will run @code{git remote update} and @kbd{F} will run
|
||||
@code{git pull}.
|
||||
@code{git pull}. You should have setup your Git configuration to do
|
||||
the right thing for @code{git pull}.
|
||||
|
||||
That's almost all the support for remote repositories that Magit
|
||||
offers. You should have setup your Git configuration to do the right
|
||||
thing for @code{git push} and @code{git pull}.
|
||||
|
||||
If you have configured a default remote repository for the current
|
||||
branch (by setting the Git config option
|
||||
@code{branch.<branch>.remote}), Magit will show that repository in the
|
||||
status buffer header.
|
||||
If there is a default remote repository for the current branch, Magit
|
||||
will show that repository in the status buffer header.
|
||||
|
||||
In this case, the status buffer will also have a @emph{Unpushed
|
||||
commits} section that shows the commits on your current head that are
|
||||
|
|
Loading…
Reference in a new issue