HOME

git-init

Git Source Control

Git Executable Path

(setenv  "PATH" (concat (getenv "PATH") ":" "/usr/local/bin" ":" "/usr/local/git/bin/"))
(setq exec-path (append exec-path '("/usr/local/bin")))
(setq exec-path (append exec-path '("/usr/local/git/bin")))

Magit

Probably the very best git front-end out there.

I like it to open full-screen and then restore my windows where they were when it is done:

(require-package 'magit)
(eval-after-load "magit"
  '(progn
     (defadvice magit-status (around magit-fullscreen activate)
       (window-configuration-to-register :magit-fullscreen)
       ad-do-it
       (delete-other-windows))

     (defun magit-quit-session ()
       "Restores the previous window configuration and kills the magit buffer"
       (interactive)
       (kill-buffer)
       (jump-to-register :magit-fullscreen))

     (define-key magit-status-mode-map (kbd "q") 'magit-quit-session)))

Quick one-button git status:

(global-set-key (kbd "<f2>") 'magit-status)

git-grep

(defun git-grep-rb (regexp)
  "Run git-grep on ruby files in the current project"
  (interactive "sSearch for (regexp): ")
  (vc-git-grep regexp "'*.rb'" (textmate-project-root)))

(defun git-grep (regexp)
  "Run git-grep on files in the current project"
  (interactive "sSearch for (regexp): ")
  (vc-git-grep regexp "'*.rb' '*.clj'" (textmate-project-root)))

vc-annotate

Built-in to Emacs and really useful. It allows you to not only view source control annotations, but also to move back and forward in time within the file. Very nice.

It's nicer, I think, when it ignores white-space:

(defun vc-git-annotate-command (file buf &optional rev)
  (let ((name (file-relative-name file)))
    (vc-git-command buf 0 name "blame" "-w" rev)))
(provide 'git-init)

Author: Toby Tripp

Created: 2015-02-04 Wed 10:41

Emacs 24.3.1 (Org mode 8.2.10)

Validate