2013-04-09 01:40:40 +02:00
#+TITLE : git-auto-commit-mode
#+STARTUP : showall
* NAME
git-auto-commit-mode - Emacs minor mode to automatically commit (and
push) a git repository.
2015-03-21 15:19:02 +01:00
[[http://melpa.org/#/git-auto-commit-mode ][file:http://melpa.org/packages/git-auto-commit-mode-badge.svg ]]
[[http://stable.melpa.org/#/git-auto-commit-mode ][file:http://stable.melpa.org/packages/git-auto-commit-mode-badge.svg ]]
2013-04-09 01:40:40 +02:00
* SYNOPSIS
=M-x git-auto-commit-mode <RET>=
* DESCRIPTION
git-auto-commit-mode is an Emacs minor mode that tries to commit
changes to a file after every save.
The commit message sent to git is always the filename of the file
saved, relative to the root of the git repository.
* USAGE
When enabled, git-auto-commit-mode uses the =after-save-hook= to
commit changes to git each time. If =gac-automatically-push-p= is
non-nil it also tries to push the ~HEAD~ to the current upstream.
Making sure that upstream is properly set is the responsibility of
the user.
** Enabling
Since git-auto-commit-mode is a regular minor mode you have more
than one option to enable it.
*** As a file-local variable
If you're using Emacs 24 or newer you should set an =eval=
file-local variable:
#+BEGIN_EXAMPLE
;; -*- eval: (git-auto-commit-mode 1) -* -
#+END_EXAMPLE
If you're using an older version of Emacs, that should be:
#+BEGIN_EXAMPLE
;; -*- mode: git-auto-commit -* -
#+END_EXAMPLE
*** As a directory-local variable
2019-12-11 06:46:05 +01:00
Create a ~.dir-locals.el~ file in the directory where you want
git-auto-commit-mode to be enabled. This will also apply to any
subdirectories, so be careful. For more information see the [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html#Directory-Variables][Per-Directory
Local Variables]] section in the Emacs manual. Then put one of the following
snippets of code in there:
2013-04-09 01:40:40 +02:00
If you're using Emacs 24 or newer you should set an =eval= variable:
#+BEGIN_EXAMPLE
((nil . ((eval git-auto-commit-mode 1))))
#+END_EXAMPLE
If you're using an older version of Emacs, that should be:
#+BEGIN_EXAMPLE
((nil . ((mode . git-auto-commit))))
#+END_EXAMPLE
*** As a hook
To enable git-auto-commit-mode each time a ~certain-hook~ runs:
#+BEGIN_EXAMPLE
(add-hook 'certain-hook 'git-auto-commit-mode)
#+END_EXAMPLE
* CUSTOMIZATION
git-auto-commit-mode is a simple mode, as such it offers little
customization.
2019-12-11 06:41:51 +01:00
- =gac-automatically-push-p= ::
A boolean value indicating whether or not git-auto-commit-mode should try to
push the git repository's ~HEAD~ to its default upstream. Setting up the
upstream is the user's responsibility.
2015-04-04 16:46:43 +02:00
2019-12-11 06:39:06 +01:00
- =gac-automatically-add-new-files-p= ::
A boolean value indicating whether or not git-auto-commit-mode should add
new (untracked) files to the repository.
2019-12-11 06:41:51 +01:00
- =gac-ask-for-summary-p= ::
A boolean value indicating whether or not git-auto-commit-mode should ask
the user for a commit message every time a commit is made. *Note* : Since the
summary is asked for before the commit, but /after/ the file has been saved,
pressing ~C-g~ while entering the Summary will stop the commit from being
made, but not the file from being saved.
- =gac-shell-and= ::
A string that can be used to change how the shell combines commands. The
default " && " is good for bash-like shells, but " ; and " would be used for
fish, for example.
- =gac-debounce-interval= ::
A number specifying a buffer between automatic commits in seconds. Wait with
making an actual commit until this number of seconds elapses.
2020-07-05 16:23:45 +02:00
- =gac-add-additional-flag= ::
A string that can be used to add additional command line flags to the ~git
add~ command.
- =gac-commit-additional-flag= ::
A string that can be used to add additional command line flags to the ~git
commit~ command.
2020-07-05 16:28:19 +02:00
- =gac-silent-message-p= ::
A boolean value indicating whether to display the commit summary message,
which is usually displayed in the minibuffer. The default is ~nil~ , meaning
that the summary would be displayed on every commit.
2020-11-18 03:27:41 +01:00
To set any of these options, you can:
- Use the customization interface (~M-x customize-group git-auto-commit-mode~ ).
- Set the defaults in your Emacs initialization file using:
#+begin_src emacs-lisp
(setq-default gac-ask-for-summary-p t)
#+end_src
- Set values in a hook:
#+begin_src emacs-lisp
(defun set-my-settings ()
(setq gac-automatically-push-p t))
(add-hook 'org-mode-hook 'set-my-settings)
#+end_src
- Set values in a ~.dir-locals.el~ (see [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html#Directory-Variables ][Per-Directory Local Variables ]]):
#+begin_src emacs-lisp
((nil . ((gac-shell-and . " ; and "))))
#+end_src