3.6 KiB
git-auto-commit-mode
<script src="/keyjs.js" type="text/javascript"></script> <script type="text/javascript"> keyjs_initialize({ "u": [ "keyjs_goto", "../index.html" ], "h": [ "keyjs_goto", "http://ryuslash.org" ] }); </script>
About
git-auto-commit-mode
is a minor mode for GNU Emacs that, when
enabled, tries to commit changes to a file after every save. It can
also try to push to the default upstream.
Status | On-hold |
Language | Emacs Lisp |
Licennse | GPLv3 |
Features
-
Automatically commit changes to a file after each save.
- The commit message will contain the file name relative to the repository root.
- Optionally, automatically push commits to the default upstream.
Download
There are download links for a tar.gz
and a zip
file of the latest
development version at the top of this page.
git-auto-commit-mode
is in the Marmalade repo.
Install
Once you have downloaded git-auto-commit-mode
you have at least 2
choices for installation.
package.el
If you have Emacs v24+ or package.el and Marmalade configured, you can just:
(package-install "git-auto-commit-mode")
manual
Otherwise you have to dowload it and then put it somewhere in your
load-path
, or add that location to your load-path
:
(add-to-list 'load-path "~/location/of/git-auto-commit-mode")
After which you can either require
the package in your Emacs init
file:
(require 'git-auto-commit-mode)
Or set-up some autoloads:
(autoload 'git-auto-commit-mode "git-auto-commit-mode" nil t)
Usage
There are a few ways this could be used:
As file-local variable
This is the way I use it and I wanted to use it. Any file that you would like to have automatically committed upon saving gets this prop-line:
;; -*- eval: (git-auto-commit-mode 1) -*-
Or, if you're in anything older than emacs 24:
;; -*- mode: git-auto-commit -*-
As a directory-local variable
Put the following in a .dir-locals.el
file in any directory where
you want to enable git-auto-commit-mode
for all files:
((nil . ((git-auto-commit-mode . t))))
As a hook
I doubt this will ever really be useful, but it is possible:
(add-hook 'some-hook 'git-auto-commit-mode)
Automatically push
If you wish to push your changes each time the file is saved you
should set gac-automatically-push-p
to t
. This is a buffer local
variable, so you will have to put it in your dir-local or
file-local variables. Alternatively, if you're sure you can also
set the default value to t
, like so:
(setq-default gac-automatically-push-p t)