Initial version of the commandset.
[gitgitconfig.git] / gitgitconfig-init
blob320e584d003b85989803a31e6c4609e5eec0948c
1 #!/bin/bash -ex
3 if ! [[ "$DATADIR" ]]; then
4 DATADIR=/usr/share/gitgitconfig
5 fi
6 readonly DATADIR
8 # We don't want (for now) to work with .git in nonstandard locations.
9 #readonly REPOCONFIGDIR="$(git rev-parse --git-dir)"
10 readonly REPODIR="$(git rev-parse --show-toplevel)"
12 cd "$REPODIR"/.git
14 git init
16 # There are 2 variants:
17 # to put the patterns under version control
18 # (so that anyone who gets the branch with this stuff can comfortably
19 # use it with plain git, without my scripts):
20 cp -v "$DATADIR"/gitignore .gitignore
22 # or:
23 # to put the patterns not under version control
24 # (so that there is no extra junk in the branch, but then
25 # it's comfortable only if everyone uses this script for init):
26 #cp -v "$DATADIR"/gitignore .git/info/exclude
28 # Don't forget to "git add .gitignore" manually afterwards...
29 # Or shoud we do this automatically as the first commit?
31 # Local FS optimizations (like "git clone --reference"),
32 # not obligatory if you do this manually.
33 # (http://git-blame.blogspot.fr/2012/08/bringing-bit-more-sanity-to-alternates.html):
34 echo ../../objects > .git/objects/info/alternates
36 git remote add -f -m GITCONFIG/master origin "$REPODIR"
37 # In order to restore your saved .git/config,
38 # we'd like to pull from GITCONFIG/master in origin
39 # (which is expected to be your main working repo that has
40 # been cloned as a mirror from a remote server)
41 # (in rare cases, you'd want to pull from some <remote>/GITCONFIG/master instead).
43 # And when saving your .git/config,
44 # we'd like to push our local master to GITCONFIG/master in origin
45 # (for further propagation to remote servers).
47 git config branch.master.remote origin
48 git config branch.master.merge GITCONFIG/master
49 git config push.default upstream
51 # We'll see whether this will work out.