For emacs 25 or newer refer to this answer. For emacs < 25 there's no automatically generated manifest file that you can synchronize to achieve the desired effect.
That said, something you can do is add calls to package-install in your emacs configuration itself.
The idea is that package-install is idempotent, so if the package ...
The problem with existing version control systems is not so much their complexity; it's the fact that there is such a wealth of information out there that it can be very difficult for beginners to see the forest for the trees (i.e., to figure out what they do and don't need to learn when they are just getting started).
This post is going to focus on git, ...
I store my Emacs configuration in Github because I use two different computers, one at work, one at home.
Here is a list about things that I don't put into source control:
Environment specified setups.
For example, my Emacs open different org file on start-up at different machine. You don't want to commit these settings into source control.
I use (...
I keep my .emacs.d directory in version control. Then, in my init.el and subsequent files I use use-package to define package setup. Not only does use-package lazily load your packages, it will download them on demand if they don't exist from whatever package repos you've set up.
For example, I use go-mode, but not on every machine. In my init.el I have ...
Dmitry Gutov's diff-hl library provides diff-hl-mode, which gives you the fringe highlighting shown in the top window in the following screenshot (with the actual diff displayed in the bottom window for comparison):
It uses the generic vc functionality in Emacs in order to be VCS-agnostic. The readme says "Tested with Git, Mercurial, Bazaar and SVN. May ...
The ws-butler package removes whitespace only from the touched lines. The package is available on Melpa.
From that package's README on github:
Only lines touched get trimmed. If the white space at end of buffer is changed, then blank lines at the end of buffer are truncated respecting require-final-newline.
Trimming only happens when saving.
In addition to magit (as @itsjeyd's answer ably demonstrates), you can also try git-timemachine, which provides facilities for quick cycling through older versions of a file under git version control. According to its github page, the following default keybindings give you a sense of what you can do:
p Visit previous historic version
n Visit next historic ...
You don't specify what version control system you're using, but if it's git, ou can use git-gutter to put an indicator in the margins when a line has been added, deleted or modified. It's available in MELPA via M-x package-install git-gutter.
You should check out Ediff. It can both display diffs and act as a (3-way) merge tool. It lets you easily revert changes, and also highlights refined differences to show you only the parts of each hunk that actually changed.
ediff-revision will let you easily compare against the most recent commit, or any previous commits.
There are lots of different ways to organize your .emacs.d. You should probably have a look at some of the great examples here and here.
Most of the time, what you want to keep under version control is your personal emacs configuration: the elisp files and directories you edit and modify to personalize your emacs.
Under my .emacs.d/, for example, I have ...
As noted in many answers to the question you have linked to and even more so in comments on those answers, git checkout source_branch -- <paths>... does not perform a merge.
Never-the-less there are of course situations when you want to do that - just don't call it a "merge". It would be much more appropriate to talk about "putting a file in the ...
What you want to use is Cask, which lets you create a Cask file specifying which packages to install on cask install. It can be used to manage dependencies of a package, and "dependencies" of your Emacs configuration with ease. Put your Cask file in under version control, and install/update packages on a per-machine basis.
use .emacs.d/init.el instead of .emacs
make your .gitignore a white list
use a package manager
I use .emacs.d/init.el instead of .emacs since this setup allows me to put .emacs.d under git. Having ~/.emacs makes you to create a symbolic link to git repository or to have git repo at your home directory. If you use .emacs.d, all is ...
Just make sure no generated stuff (like @rangi-lin notes) is in the repo and, if you're sharing your dotfiles with others, no related security stuff (like passwords and API keys). For the later I've split my customizations into a separate file with:
(setq custom-file (concat dotfiles-dir "custom.el"))
(load custom-file 'noerror)
Occasionally I move "safe" ...
I suspect you'll find Backups Mode and/or Backup Walker very interesting.
Both aim to leverage the existing backup mechanisms in Emacs, and provide better access to and visibility of your file history, without requiring an additional VCS.
When using magit:
Use l -al l to view the revisions of all branches in your history
go to the line containing the revision you want to compare your current buffer content against.
Type d and you are asked for which revision to compare the current working tree against (the default is the revision at point). Confirm.
You'll get a diff overview over changes of ...
Emacs is doing what you told it to do instead of what you meant. ediff-revision asks for three pieces of information:
The file to work on — default: the file that the current buffer is visiting.
The old revision — default: the latest revision.
The new revision — default: the current state.
At step 1, you select the file, you aren't telling Emacs that you ...
An alternative approach would be the following: since I do not only want to synchronise my Emacs packages, but also other files (e.g. .emacs, .bashrc, but also other directories) between my server and my laptop, I started to use unison, to sync the files and directories. So when working on my laptop I simple run unison laptop before anything else. My ~/....
As was mentioned, a simple way to have different versions of a file is Emacs backup system.
(setq backup-directory-alist '(("." . "~/emacs-backups"))
This will use a dedicated directory for numbered backups, which will never automatically deleted. Then you can use ...
Magit should only revert a file-visiting buffer if the file has actually changed on disk, see magit-revert-buffers. That function uses verify-visited-file-modtime to determine whether that is the case. Committing does not change any files, so you should not see any messages about files being reverted. Maybe something else, like e.g. a commit hook, is ...
Here is a piece of advice that shortens Git to G, while leaving mode line strings for other version control systems unchanged:
(defun my-shorten-vc-mode-line (string)
((string-prefix-p "Git" string)
(concat "G" (substring string 3)))
(advice-add 'vc-git-mode-line-string :filter-return 'my-shorten-vc-mode-line)
It uses ...
Here are two alternative answers, which both come from reading the Emacs manual, node Backup Names:
Set variable version-control to nil, and then create a numbered backup for each of your "important" files (only). Files that already have numbered backups will continue to get them. Other files will not get numbered backups.
"[S]et version-control locally ...
I have the following things in my .hgignore
emacs server file
recentf file: File paths on one machine do not make sense on another
elpa/melpa directory: Use init file to automatically install required packages and save pull/push times.
If you want to share your init with others, you might consider removing any history files such as the one created by ...
Perhaps an even better idea is to use ws-butler, a mode that unobtrusively trims the relevant trailing whitespace whenever the buffer is saved (be it from auto-indentation or some other source). Even better, it tracks your changes, and only cleans up the lines you touch, which is handy for editing with other people who aren't so tidy under VC.
Just M-x ...
While package.el is the standard way to install packages, you might also want to try el-get which is very useful for installing packages which are not (or cannot be) on elpa. This answer deals with synchronizing such packages.
The way you ensure that given packages are installed when using el-get is to add something like the following to you init file
I use a little trick "stolen" from emacs-starter-kit (I think):
(defun maybe-install-and-require (p)
(when (not (package-installed-p p))
So when I require a package, I simply use:
On emacs startups, evaluating my config, package.el will provide to install magit if it's not ...
Since around Emacs-24, the vc-log buffer supports/expects an RFC822-style format, with some headers handled specially (e.g. Author:, Fixes:, and Summary:). In Emacs-24.4, the default message content was changed to make this more clear.
When using diff-hl and magit => v2.4.0 you have to add this:
(add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh)
As far as the information in the mode-line is concerned, I would recommend just ignoring that (or even removing it completely). The function which updates that is actually fairly inefficient, so one could say it is a good thing it ...
Yes, VC is structured so as to be easy to add new backends. The main code is in vc.el, and then each backend has a vc-<backend>.el file.
Check all the vc-<backend>.el provided with Emacs to see what is needed. Basically, you'll want to start by defining a vc-<backend>-registered function which returns non-nil if the file is under control ...