48

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. (package-install 'auctex) The idea is that package-install is idempotent, so if the package is already present, nothing will actually happen. Assuming ...


43

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, ...


35

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 (...


34

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 ...


29

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 ...


17

In Emacs-25, there is the variable package-selected-packages, so you can customize this variable and use package-install-selected-packages to make sure they're installed.


14

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.


11

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 ...


10

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.


10

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.


10

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 ...


10

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 ...


9

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.


8

tl;dr use .emacs.d/init.el instead of .emacs make your .gitignore a white list use a package manager .emacs.d/init.el 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 ...


8

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" ...


8

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.


7

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 ...


7

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 ...


7

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 ...


7

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 ...


6

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 ...


6

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 ~/....


6

As was mentioned, a simple way to have different versions of a file is Emacs backup system. (setq backup-directory-alist '(("." . "~/emacs-backups")) version-control 'numbered make-backup-files t delete-old-versions 'never) This will use a dedicated directory for numbered backups, which will never automatically deleted. Then you can use ...


6

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) (cond ((string-prefix-p "Git" string) (concat "G" (substring string 3))) (t string))) (advice-add 'vc-git-mode-line-string :filter-return 'my-shorten-vc-mode-line) It uses ...


6

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 ...


5

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.


5

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 (el-...


5

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 ...


5

Solution The problems turned out to be caused by the customization variable auto-revert-check-vc-info. If this setting is active, the version control software – git in my case – will be invoked every auto-revert-interval seconds (default 5) for each repository, causing the described behavior. The only solutions I found were to increase the interval (...


5

You can bookmark any file, or any part of a code/text file. You can even bookmark a region (and have the region activated when you jump to the bookmark). A bookmark can have an annotation, and that annotation can be simple text or a separate Org file. Bookmarks are saved in a separate file from the places they bookmark. (And you can have multiple bookmark ...


Only top voted, non community-wiki answers of a minimum length are eligible