Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't think your setup is bizarre. I know at least one guy who has an emacs hook to commit his repo every time he saves a file (he's an xemacs maintainer btw).</p> <p>There is a perfectly clean way of doing what you want, thanks to the <code>GIT_DIR</code> and <code>GIT_WORK_TREE</code> variables. For example, given any Git repository, you can setup an "autocommit" repository that's independent from the "official" repository that you push to GitHub.</p> <h3>Initializing an autocommit repo</h3> <pre><code>cd /path/to/project export GIT_DIR=/tmp/autocommit.git export GIT_WORK_TREE=$PWD git init git add . git commit -m init </code></pre> <h3>Updating an autocommit repo = autocommit.sh</h3> <pre><code>#!/bin/sh export GIT_DIR=/tmp/autocommit.git ## same path as you initialized export GIT_WORK_TREE=/path/to/real/project ## same path as you initialized git add --all ## --all takes care of deletes too git commit -m auto-commit </code></pre> <p>That's it. The two repos don't even need to know of the existence of the other.</p> <p><strong>UPDATE</strong></p> <p>To answer to your follow-up questions:</p> <blockquote> <p>if I used GIT_DIR to create a second repo in the same directory, would I also have to export GIT_DIR=/tmp/.git before committing my manual commits? </p> </blockquote> <p>For your manual commits, don't use these variables at all. Use the Git repository as you normally would. The autocommit repo is completely independent, it doesn't affect your regular repo in any way. In short, no setup needed for your regular use.</p> <blockquote> <p>I work mostly on Windows and I'm not sure if the GIT_DIR environment variable will work - can I use git --git-dir=... just as effectively?</p> </blockquote> <p>I suggest to wrap the autocommiter into its own script, where it can setup the environment variables it needs. Since you have multiple autocommit repos, maybe you want to create a common <code>autocommit.sh</code> that takes parameters, which you call from wrapper scripts, one per repo. For example. This is just one way of doing it.</p> <blockquote> <p>is it possible to change the git directory of an existing repo? Is it as easy as renaming the .git folder? Because I already have four or five projects auto-committing to the default repo instead of autocommit.git and I would like to change these.</p> </blockquote> <p>I suggest to keep your regular repo as is. Create new clones for autocommit like this:</p> <pre><code>git clone --bare /path/to/proj1 /my/autocommits/proj1.git </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload