What if you wanted to version-control just ONE script, among a directory of other scripts? Could each individual script have its own separate git repository, even though they're in the same directory?
Yes, by setting --git-dir and --work-tree to the appropriate settings.
The attached Bash alias (function ogit()) does this for you.
'ogit' is a wrapper for 'git', call it almost exactly like you would call 'git'. The only thing that has been added is the command "ogit use", which designates the ogit repo that you will use for all future 'ogit' calls:
$ ls -lA drwxr-xr-x 8 dee dee 4096 Feb 27 16:37 .git.one.txt/ -rw-r--r-- 1 dee dee 10 Feb 27 16:11 one.txt -rw-r--r-- 1 dee dee 26 Feb 27 16:39 two.txt $ ogit You must first set a OneGit repository first, using 'ogit use <filename>' $ ogit use ./two.txt Initialized empty Git repository in /home/dee/docs/.git.two.txt/ OneGit is now using: ./two.txt $ ls -lA drwxr-xr-x 8 dee dee 4096 Feb 27 16:37 .git.one.txt/ drwxr-xr-x 8 dee dee 4096 Feb 27 16:42 .git.two.txt/ -rw-r--r-- 1 dee dee 10 Feb 27 16:11 one.txt -rw-r--r-- 1 dee dee 26 Feb 27 16:39 two.txt $ ogit status # On branch master # # Initial commit # # Untracked files: # (use "git add
..." to include in what will be committed) # # two.txt nothing added to commit but untracked files present (use "git add" to track) $ cat .git.two.txt/info/exclude * !two.txt $ ogit add two.txt $ ogit commit -m 'initial commit' Created initial commit d39b940: initial commit 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 two.txt $ ogit log commit d39b940066a130f1cbd597280056d9c5aa7d637e Author: Dee Newcum Date: Mon Feb 27 16:42:06 2012 -0500 initial commit $ ogit use ./one.txt OneGit is now using: ./one.txt $ ogit log commit 2db7a4d5299584fae9af50bfd91f66fd888d4abf Author: Dee Newcum Date: Mon Feb 27 16:29:25 2012 -0500 initial commit