在git中切换分支时,如何获得Emacs还原所有不变的缓冲区? [英] How can I get Emacs to revert all unchanged buffers when switching branches in git?

查看:241
本文介绍了在git中切换分支时,如何获得Emacs还原所有不变的缓冲区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,当我在git中切换分支时,如果文件在emacs中打开,那么emacs会询问我是否要恢复它们(因为它认为它们在磁盘上已经更改),即使内容是相同的。



首先,如果磁盘上的内容与缓冲区中的内容相同,首先我想找到一个emacs的方法,不要问我。



其次,我想要一个恢复(不查询)所有没有未保存更改的打开缓冲区的命令,并询问有关未保存更改的缓冲区。



或者,我可以提出有关其他解决方案,工作方式等的建议。如果人们可以给我指点哪里开始,我相当开心。如果有重要的话,我在OSX上使用Aquamacs。



编辑:



嗯,我已经发现了几乎所有我需要的revbuffs包。当然足够阻止我想要尝试写任何新的东西。 (我将驱动映射到Cmd-R,它的工作相当不错,其他Mac应用程序类似于Cmd-R)。



全局自动还原模式一个完美的解决方案,我希望我可以选择两个答案。我只是因为想要控制发生什么的可能是非理性的感觉而更喜欢revbuffs。



我猜到,如果我从内部访问了git emacs,那么它可能会更容易处理,但我现在更喜欢通过命令行访问git。 (我还没有使用emacs足够长,使其成为我的操作系统)。我会调查magit一点点。



Edit2:



我一直在使用magit现在,可以强烈推荐它来处理emacs中的git。但是,当我在emacs之外进行rebase时,我仍然使用revbuffs。

解决方案

尝试 revbufs包


revbufs.el 是一个微小的Emacs包,当您在Emacs和外部工具中编辑文件时,可以安全地恢复缓冲区(例如,代码生成器,如 Jomtool )...



Often, when I switch branches in git, if the files are open in emacs, then emacs asks if I want to revert them (as it thinks they've changed on disk) even though the contents are identical.

Firstly I'd like to find a way for emacs to not ask me about it at all if the contents on disk are identical to those in the buffer.

Secondly I'd like a command that reverted (without query) all my open buffers that have no unsaved changes, and queried me about those that do have unsaved changes.

Alternatively, I'd be open to suggestions about other solutions, ways of working, etc I could try. I'm fairly happy writing emacs-lisp if people can give me pointers on where to start.

PS I'm using Aquamacs on OSX if that matters.

Edit:

Well, I've found the revbuffs package to be pretty much what I need. Certainly enough to stop me wanting to try and write anything new myself. (I mapped revbuffs to Cmd-R which works quite nicely. Kind of similar to Cmd-R in other Mac apps).

Global-auto-revert mode would have been a perfectly fine solution, and I wish I could choose two answers. I prefer revbuffs simply because of a, possibly irrational, feeling of wanting to be in control of what happens.

I'd kind of guessed that if I accessed git from within emacs, then it could probably be handled easier, but I currently prefer accessing git through the commandline. (I haven't quite been using emacs long enough to make it my operating system). I will investigate magit a little more thoroughly though.

Edit2:

I've been using magit for a year now and can highly recommend it for dealing with git from within emacs. However I still use revbuffs whenever I do a rebase outside of emacs.

解决方案

Try the revbufs package:

revbufs.el is a tiny Emacs package that safely reverts your buffers when you have files being edited both in Emacs and via external tools (e.g., code generators such as Jomtool)...

这篇关于在git中切换分支时,如何获得Emacs还原所有不变的缓冲区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆