restore: Implemented with rebase and reset. (Do not forget to reset manually in case...
[gitgitconfig.git] / gitgitconfig-save
blob0c62e0eef868de3c87bb163e972dccbc3a204463
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)"
6 readonly REPODIR="$(git rev-parse --show-toplevel)"
8 cd "$REPODIR"/.git
10 if [[ -d .git ]]; then
11 # Already initialized.
12 # Please, add and commit interesting files beforehand manually.
14 else
15 # Not initialized.
16 pushd ..
17 gitgitconfig-init
18 popd
19 git add .
20 git commit -m 'Saving your .git/config etc. automatically.'
23 # I wanted to squash all local changes into one commit (to avoid
24 # the extra junk from the inital config), but that's not a trivial command.
25 #git rebase
27 # We'd like to push our local <branches> to GITCONFIG/<branches>
28 # in your main working repo.
29 git push origin refs/heads/*:refs/heads/GITCONFIG/*
30 # (In our gitgitconfig-init, we have set up such behavior for master only).
32 # Then take care to propagate GITCONFIG/master to all your remotes
33 # when pushing from your main repo.