I normally use only a few git commands each time I want to commit changes to a repository:

$ git add --all .
$ git commit -m "update."
$ git push -u origin master

Can magit be useful in this regard? M-x magit-status seems helpful but I am not fulling understanding the language of "staging/unstaging" "hunks" etc. from ref1 ref2 ref3.

What might be the equivalent commands in magit? Thanks in advance -

Edit This page seems to speak better to my level but is C-u s the equivalent of git add --all .? Though that page says it does not work.

  • For simple git use, the vc-mode commands are perfectly suitable. I do use magit for complex commits etc., but for simple cases vc is excellent.
    – éric
    Jan 9, 2021 at 13:03

3 Answers 3

  • S stages all files
  • c c initiates a commit. Write the message and then press C-c C-c to actually create the commit.
  • P u pushes to the upstream branch. In the popup that appears after you have pressed P you can see the upstream. If the upstream is not set yet, then you can still use P u. You'll be asked for a branch which is then configured as the upstream before pushing.

This one is also quite easy technique without learning shortcuts of magit by using hydra.

(defhydra yt-hydra/help (:color blue :hint nil)
_mp_ magit-push #_mc_ magit-commit #_md_ magit diff #_mla_ magit diff #_mla_ magit status
  ;;Magit part
  ("mp" magit-push)
  ("mc" magit-commit)
  ("md" magit-diff)
  ("mla" magit-log-all)
  ("ms" magit-status)
(global-set-key (kbd "<f1>") 'yt-hydra/help/body)

I just write an easy shell function to help PUSHING ALL.

function lazy-git {
    git add -A
    git commit -a -m "🍁  $1"
    git push

lazy-git "Update somethinng"

or in Emacs

(defun push-all (comment)
  (interactive (list
            (read-string (format "🔥 Push for [%s]: " (current-directory-name)))))
  (save-some-buffers t) ; save all buffer
  (shell-command (format "git add -A; git commit -a -m \" %s\"; git push &"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.