diff options
author | Kyle Meyer <kyle@kyleam.com> | 2015-05-10 22:27:40 -0400 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2015-05-10 22:27:40 -0400 |
commit | 698b58947ad364134929272d544646d8f9b0967a (patch) | |
tree | 96f7b79d0a801f10c92b8d82ddb6df1dbc09caaf | |
parent | 2e3cc33ae76d8c05376c52d7333b0af489839259 (diff) | |
download | emacs.d-698b58947ad364134929272d544646d8f9b0967a.tar.gz |
Add command magit-checkout-file
-rw-r--r-- | lisp/init-git.el | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lisp/init-git.el b/lisp/init-git.el index f12389b..108d26c 100644 --- a/lisp/init-git.el +++ b/lisp/init-git.el @@ -178,6 +178,15 @@ and 'squash!' titles." (goto-char (apply #'max commit-pts)) (message "No matching commits found")))) +(defun km/magit-checkout-file (rev file) + "Checkout FILE from revision REV. +\n(git checkout REV -- file)" + (interactive + (let ((rev (magit-read-branch-or-commit "Revision"))) + (list rev (magit-read-file-from-rev rev "File")))) + (let ((default-directory (magit-get-top-dir))) + (magit-run-git "checkout" rev "--" file))) + (defun km/magit-pin-file (&optional other-rev) "Pin this file to the current revision. @@ -251,6 +260,7 @@ the file name if NO-DIRECTORY is non-nil." (define-key km/git-map "c" 'km/magit-show-commit-under-point) (define-key km/git-map "C" 'km/magit-show-project-commit-under-point) (define-key km/git-map "e" 'km/magit-commit-extend-all) + (define-key km/git-map "f" 'km/magit-checkout-file) (define-key km/git-map "p" 'km/magit-pin-file) (define-key km/git-map "s" 'km/magit-insert-staged-file) (define-key km/git-map "u" 'km/magit-auto-commit)) |