Ignore also temporary files like COMMIT_EDITMSG, FETCH_HEAD, etc.
[gitgitconfig.git] / gitgitconfig-init
blobd77a8ca939f3c6239f9a9835b4f9262e1abd2054
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" afterwards...
30 # Local FS optimizations (like "git clone --reference")
31 # (http://git-blame.blogspot.fr/2012/08/bringing-bit-more-sanity-to-alternates.html):
32 echo ../../objects > .git/objects/info/alternates
33 # Perhaps, you can skip this if you are following this sequence of commands manually.
35 git remote add -f -m GITCONFIG/master origin "$REPODIR"
36 # In order to restore your saved .git/config,
37 # we'd like to pull from some <remote>/GITCONFIG/master in origin
39 # And when saving your .git/config,
40 # we'd like to push our local master to GITCONFIG/master in origin
41 # (for further propagation to remote servers).
43 git config branch.master.remote origin
44 git config branch.master.merge GITCONFIG/master
45 git config push.default upstream
47 # We'll see whether this will work out.