Implemented automatic init in save and restore (to be more usable).
[gitgitconfig.git] / gitgitconfig-restore
blob1eb9db6fe9165f40f02b94ebe86e06920f554b89
1 #!/bin/bash -ex
3 # We don't want (for now) to work with .git in nonstandard locations.
4 #readonly REPOCONFIGDIR="$(git rev-parse --git-dir)"
5 readonly REPODIR="$(git rev-parse --show-toplevel)"
7 cd "$REPODIR"/.git
9 if [[ -d .git ]]; then
10 # Already initialized.
11 # Please, add and commit interesting files beforehand manually,
12 # otherwise merge will fail.
14 else
15 # Not initialized.
16 pushd ..
17 gitgitconfig-init
18 popd
19 git add .
20 git commit -m 'Initial .git/config etc. (needed for automatic operation).'
23 # We'd like to pull from some <remote>/GITCONFIG/master in origin
24 # (which is expected to be your main working repo)
25 # to restore your saved .git/config.
26 if [[ "$1" ]]; then
27 git pull origin "$1"/GITCONFIG/master
28 else
29 # Pulling from GITCONFIG/master in origin.
30 # (We have set up such behavior in our gitgitconfig-init.)
31 git pull
32 # Unfortunately, this is rarely useful, because your main
33 # working repo won't be a mirror of a remote, and hence won't
34 # have GITCONFIG/master after a clone.
37 # We'll see how merging works out.