summaryrefslogtreecommitdiffstats
path: root/site/projects/git-auto-commit-mode.org
blob: c7b0b990e5aa9bec0457849f0c1cb8a76473eaf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#+TITLE: git-auto-commit-mode
#+STYLE: <link rel="stylesheet" type="text/css" href="../../stylesheet.css" />
#+LINK_UP: ../index.html
#+LINK_HOME: http://ryuslash.org
#+LINK: src    https://github.com/ryuslash/git-auto-commit-mode
#+LINK: tar_gz https://github.com/ryuslash/git-auto-commit-mode/tarball/master
#+LINK: zip    https://github.com/ryuslash/git-auto-commit-mode/zipball/master
#+STARTUP: showall

#+begin_html
  <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>
#+end_html

#+INCLUDE: "dlmenu.inc"

* About

  ~git-auto-commit-mode~ is a minor mode for GNU
  Emacs[fn::http://gnu.org/software/emacs/] that, when enabled, tries
  to commit changes to a file after every save.  It can also try to
  push to the default upstream.

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

** Requirements

   These should be mostly obvious.

   - [[http://gnu.org/software/emacs][GNU Emacs]]
   - [[http://git-scm.com][git]]

* Usage

  To be able to use it you need to put it somewhere in your
  ~load-path~ and load it, for example:

  #+begin_src emacs-lisp
    (add-to-list 'load-path "~/path/to/git-auto-commit-mode.el")
    (auto load 'git-auto-commit-mode "git-auto-commit-mode")
  #+end_src

** Automatically commit

   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:

    #+BEGIN_SRC emacs-lisp
      ;; -*- eval: (git-auto-commit-mode 1) -*-
    #+END_SRC

    Or, if you're in anything older than emacs 24:

    #+BEGIN_SRC emacs-lisp
      ;; -*- mode: git-auto-commit -*-
    #+END_SRC

*** 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:

    #+BEGIN_SRC emacs-lisp
      ((nil . ((git-auto-commit-mode . t))))
    #+END_SRC

*** As a hook

    I doubt this will ever really be useful, but it is possible:

    #+BEGIN_SRC emacs-lisp
      (add-hook 'some-hook 'git-auto-commit-mode)
    #+END_SRC

** 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:

   #+begin_src emacs-lisp
     (setq-default gac-automatically-push-p t)
   #+end_src