【问题标题】:Undo-tree style git in terminal终端中的撤消树样式git
【发布时间】:2013-02-08 09:07:07
【问题描述】:

有一个适用于 Emacs 的包,它可以让您使用撤消树,而不是仅仅通过撤消前进和后退:http://www.emacswiki.org/emacs/UndoTree

git 有没有类似的东西,它可以让你查看提交树并选择一个?在命令行还是在 Emacs 中?

注意:我是 Emacs 新手,我已经安装了出色的 Emacs Live - https://github.com/overtone/emacs-live - 这似乎包括 magit。 Emacs Live 有一个添加自定义的系统 - 文件放在 ~/.live-packs/cannyboy-pack/ 中。其中有一个 init.el 文件,它引用另一个文件夹中的文件 - config。所以我添加了 (live-load-config-file "magit-custom.el") 并在 config 中添加了一个带有@event_jr 代码的 magit-custom.el 文件,然后在 ~/.live-packs/cannyboy-pack 中引用了它/init.el 通过添加 (live-load-config-file "magit-custom.el")

【问题讨论】:

    标签: git emacs


    【解决方案1】:

    在 Emacs 中,您可以看到文件的 git 提交日志树与 magit 的 magit-file-log 命令,然后按 RETURN 打开日志的差异。我们可以 建立在 magit 和 Emacs 的内部版本控制感知功能之上 直接访问文件。

    1. 下载安装magit
    2. 添加到您的“init.el”

      (defun my-magit-visit-file-at-commit (&optional other-window)
        "Visit current commit's file in another window.
      
      This command makes sense from a `magit-file-log' buffer. "
        (interactive "P")
        (magit-section-action (item info "visit")
          ((commit)
           (let ((filename (expand-file-name (car magit-refresh-args)
                                             (concat (magit-git-dir) "../"))))
             (if (file-readable-p filename)
                 (progn
                   (find-file-noselect filename)
                   (with-current-buffer (find-buffer-visiting filename)
                     (vc-revision-other-window info)))
               (message "not able to access %s" filename))))))
      
      (eval-after-load "magit.el"
        '(define-key magit-log-mode-map (kbd "C-c o") 'my-magit-visit-file-at-commit))
      
    3. 重启 Emacs

    4. 打开您对其提交历史感兴趣的文件。
    5. M-x magit-file-log
    6. 转到有趣的提交按 C-c o

    edit 修复缺少的键盘映射规范。

    【讨论】:

    • 谢谢,我已经为我的问题添加了一些细节。我无法让您的代码正常工作(define-key 语句中没有足够的参数)。所以我把它改成了 '(define-key global-map (kbd "C-c o") 等等……但是我在 minibuffer 中得到这个错误:无法访问/path/to/code/MyCode/HEAD
    • 抱歉,它工作正常。我要进入 magit-log 而不是 magit-file-log。感谢您的代码。仍然不确定我是否应该使用 global-map。
    • 它将带有提交号的文件放在文件名之后,比如文件名。~512b384~ ...它可以完全替换文件,还是这违背了git的哲学?
    • 我修复了代码以指定正确的键盘映射。可以替换工作树文件的内容,但这很快就会让人感到困惑。
    • 我从 elpa (20151006.1359) 获得了最新版本的 magit Symbol's function definition is void: magit-section-action,我不得不使用 global-map,因为 magit-log-mode-map 不再有效。
    【解决方案2】:

    我认为magit 是您正在寻找的。 Here is a good tutorial 显示它的用途。

    你也应该看看Egg,据说有更好的用户界面。

    【讨论】:

      猜你喜欢
      • 2015-10-17
      • 1970-01-01
      • 2013-05-17
      • 2014-10-01
      • 2010-11-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多