如何使用 emacs 中的 git

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5925372/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 05:26:15  来源:igfitidea点击:

How to use git from emacs

gitemacs

提问by myglc2

The previous answers on this topic seem out of date so I am asking again in search of more timely info.

以前关于这个主题的答案似乎已经过时,所以我再次询问以寻找更及时的信息。

I use emacs development sources (24.0.50.1) to build my own emacs. Yes, I drank the Kool-Aid.

我使用 emacs 开发源 (24.0.50.1) 来构建我自己的 emacs。是的,我喝了 Kool-Aid。

I recently started using git to clone development repositories and for my own projects. I want to use of git from within emacs, and I only want to learn one interface.

我最近开始使用 git 来克隆开发存储库和我自己的项目。我想在 emacs 中使用 git,而且我只想学习一个界面。

It appears that vc-git and magit are the leading choices. Is that right?

看来 vc-git 和 magit 是首选。那正确吗?

It looks like vc-git would be the way to go if I often used other VC systems (which I don't), and that magit is the best fit since I only plan to use git.

如果我经常使用其他 VC 系统(我不使用),看起来 vc-git 将是要走的路,而 magit 是最合适的,因为我只打算使用 git。

Does that sound right? Or am I missing something?

听起来对吗?或者我错过了什么?

回答by sanityinc

Magit is a wonderful choice because it gives you a good project-level view of your repo and its history, and lets you do neat things like stage/unstage individual diff hunks in the files you've edited. Plus, it's very actively used and maintained.

Magit 是一个不错的选择,因为它为您提供了一个很好的项目级别的仓库视图及其历史记录,并让您可以在您编辑的文件中做一些整洁的事情,例如暂存/取消暂存个别差异大块。另外,它的使用和维护非常积极。

I personally use vc-git in addition to magit; it's handier than magit for various operations on the current file, e.g. viewing a diff (C-x v =), getting the file's history (C-x v l) or reverting the file to a pristine state (C-x v u).

除了magit,我个人还使用vc-git;对于当前文件的各种操作,它比 magit 更方便,例如查看差异 ( C-x v =)、获取文件的历史记录 ( C-x v l) 或将文件恢复到原始状态 ( C-x v u)。

BTW, magit's home on the web recently changed to this: https://github.com/magit/magit

BTW,最近magit在网上的主页改成了这个:https: //github.com/magit/magit

回答by Mauvis Ledford

I use and love Magit. It's easy to installon other systems if you need. The commands I use often are:

我使用并喜欢 Magit。如果需要,可以轻松安装在其他系统上。我经常使用的命令是:

C-i- While having any file open to open up the Magit "changes" window to see my changes to all files. Pressing tab on any filename and I get a colored diff of all changes. Pressing sstages them or kreverts the file (and any buffers using the file.) Pto push all my staged changes.

C-i- 打开任何文件以打开 Magit“更改”窗口以查看我对所有文件的更改。在任何文件名上按 Tab 键,我会得到所有更改的彩色差异。按暂存s它们或k还原文件(以及使用该文件的任何缓冲区。)P以推送我所有暂存的更改。

I also see all my stashesand can tab on any of them to see a diff, kto drop them. All commands are so consistent.

我还可以查看我的所有内容,stashes并且可以点击其中任何一个以查看差异,k以删除它们。所有的命令都是如此一致。

Doesn't get much easier and smooth than that!

没有比这更容易和顺利的了!

Full doc here.

完整文档在这里

回答by manojlds

Just have a look here: http://www.emacswiki.org/emacs/Git

看看这里:http: //www.emacswiki.org/emacs/Git

IMO Egg, fork of Magit, is good too.

IMO Egg,Magit 的叉子,也不错。