Skip to content

Latest commit

 

History

History
73 lines (59 loc) · 1.97 KB

starter-kit-vc.org

File metadata and controls

73 lines (59 loc) · 1.97 KB

Starter Kit Version Control

This is part of the Emacs Starter Kit.

Starter Kit Version Control

Git and Magit

Basics

  • Use Ido with Magit.
  • Setting the full path for Git makes Magit a little bit faster.
(setq magit-completing-read-function 'magit-ido-completing-read)
(setq magit-git-executable (executable-find "git"))

Resolve merge confliction

Use magit-ediff e on un-merged item.

Git checkout single file

Use magit-discard-item k on item.

Disable version control in Emacs

I almost never use version control system bundled with Emacs and it always slows down Emacs. Disable it completely.

(setq vc-handled-backends nil)

Disable backup files

I always handles my project and important files through Git so there is no need for backup files.

(setq make-backup-files nil)

Compare current buffer and its auto save file

(defun ediff-buffer-with-auto-save ()
  "Find and display differences between current buffer and its auto save
file."
  (interactive)
  (let ((auto-save-file-name
         (make-auto-save-file-name)))
    (if (file-exists-p auto-save-file-name)
        (ediff-buffers (current-buffer)
                       (find-file-noselect (make-auto-save-file-name)))
      (user-error "Current buffer has no auto save file!"))))

To compare current buffer with its associated file, use diff-buffer-with-file.

Git gutter

(defun toggle-git-gutter-and-linum ()
  (interactive)
  (cond
   ((and linum-mode git-gutter-mode)
    (git-gutter-mode -1))
   ((and linum-mode (not git-gutter-mode))
    (linum-mode -1)
    (git-gutter-mode 1))
   ((and (not linum-mode) git-gutter-mode)
    (git-gutter-mode -1)
    (linum-mode 1))
   (t
    (linum-mode 1))))