Of course there are packages on packages for working with version control systems, the most popular of which is Git.

The most widely acclaimed Emacs package is an elaborate elisp wrapper for git called Magit. You may like using it, or you may find it slow compared to runnning commands in a simple git shell, depending also possibly on your operating system.

I personally do not use Magit often; however, I do use it for git commands I don't remember or to check things like status of files in a repo, or remote address configurations.

If you explore it further surely you will find many efficiency enhancing features.

Magit


;add git to the exec path
(add-to-list 'exec-path git-dir-p)
(use-package magit
:commands (magit-status magit-blame magit-status-fullscreen magit-dispatch)
:config
(setq magit-git-executable git-exe-p)
; magit-status
; magit-blame
;:custom
;(magit-display-buffer-function #'magit-display-buffer-same-window-excep-diff-v1)
);

Git Gutter

You can use Git Gutter to easily view which lines have file level changes, or which files have changes.

If using Windows, 'find' program configuration may be necessary.


;git-gutter
(use-package git-gutter
:commands (global-git-gutter-mode git-gutter)
:config
;(global-git-gutter-mode t)
;:custom
;update git-gutter info when switching windows
(add-to-list 'git-gutter:update-commands 'other-window)
;:custom
;git-gutter:update-interval
(custom-set-variables
 '(git-gutter:update-interval 2)
 '(git-gutter:window-width 2)
 '(git-gutter:modified-sign "*") ;; two space
 '(git-gutter:added-sign "++")    ;; multiple character is OK
 '(git-gutter:deleted-sign "--")
 '(git-gutter:lighter " GG");diminish
; '(git-gutter:hide-gutter t)
);end custom-set-variables
;customize faces
(set-face-background 'git-gutter:modified "purple") ;; background color
(set-face-foreground 'git-gutter:added "green")
(set-face-foreground 'git-gutter:deleted "red")
);end package git gutter

Git Time Machine

Easily the best way to view previous file versions in a repo.


(use-package git-timemachine
:commands (git-timemachine-toggle )
:config
(setq git-timemachine-abbreviation-length 12)
(setq git-timemachine-show-minibuffer-details t)
);end use-package git-timemachine

Git Hydra

Nify hydra. You can add a function to pop open a git shell as well. I use an executables hydra for that.


;define a title function
(setq git-central-title (with-octicon "globe" "Git Manager"))
;generate hydra
(pretty-hydra-define Git-Central (:title git-central-title :quit-key "q" :color blue )
("Git Gutter"
(
    ("+" git-gutter-mode "Turn Gutter On" )
    ("@" git-gutter-global-mode "Turn Gutter On Global")
    ("u" git-gutter:popup-diff "Diff Popup" :color red)
    ("p" git-gutter:previous-hunk "Previous Hunk" :color red)
    ("n" git-gutter:previous-hunk "Next Hunk" :color red)
    ("e" git-gutter:end-hunk "End Of Hunk" :color red)
    ("s" git-gutter:stage-hunk "Stage Hunk" :color red)
    ("r" git-gutter:revert-hunk "Revert Hunk" :color red)
    ("*" git-gutter:mark-hunk "Mark Hunk" :color red)
);end theme
"Git Time Machine"
(
    ("t" git-timemachine-toggle "Toggle Time Machine")
    ("b" git-timemachine-show-previous-revision "Back In Time" :color red)
    ("f"  git-timemachine-show-next-revision  "Forward In Time":color red)
    ("w"  git-timemachine-kill-revision "Cut Revision" :color red)
    ("9" git-timemachine-show-nth-revision "Show Nth Revision" :color red)
    ("B" git-timemachine-blame "Magit Blame on Hunk")
    ("$" git-timemachine-show-commit "Magit Show Commit")
    ("x"  git-timemachine-quit "Quit Time Machine")
);end highlighting
"Magit"
(
    ("m" magit-status "Magit Status")
    ("d" magit-dispatch "Magit Manager (h)")
    ("g" magit-global-status "Start Magit Globally")
    ("I" magit-init "Initialize Magit")
    ("c" magit-clone "Clone Repository")
    ("h" hydra-helm/body "Return To Helm" :color blue )
    ("<SPC>" nil "Quit" :color blue)
);end other
);end hydra body
);end pretty-hydra-appearance
(bind-key "<C-m> g" 'Git-Central/body)

Notes

Just to recap there are many Emacs code posts in the backend of Reading World Magazine. You're welcome to browse them.

Mastering Emacs is an incredible useful thing to do, if you will be doing research, writing, software development or other text editor based tasks.

Keep in mind, however, it takes years to master Emacs. If you choose to, you are better off to get some instruction.

That’s all for now…