I am trying to create a git alias that would output the commands to build my git aliases
So far I have this
git config --global --get-regexp alias.* | sed 's/\(alias\.[^ ]\+\) \(.*\)/git config --global \1 \2/'
which yields
git config --global alias.lg log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
git config --global alias.pu !git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)
git config --global alias.puf !git push --force --set-upstream origin $(git rev-parse --abbrev-ref HEAD)
git config --global alias.r !git fp && GIT_SEQUENCE_EDITOR=true git rebase -i --autosquash origin/HEAD
git config --global alias.fr !git fp && git pull --rebase origin HEAD
git config --global alias.fp fetch --prune
git config --global alias.ac !git add -A && git commit
git config --global alias.amend commit --amend -a --reuse-message=HEAD
git config --global alias.remaster rebase -i origin/HEAD
git config --global alias.rh rehead
git config --global alias.rehead !git fetch && git checkout origin/HEAD -b
But I want it so that the text after the config name would be quoted. e.g.
git config --global alias.rehead '!git fetch && git checkout origin/HEAD -b'
I got as far as
git config --global alias.aliases '!'"git config --global --get-regexp alias.* | sed 's/\(alias\.[^ ]\+\) \(.*\)/git config --global \1 '\''\2'\''/'"
but that last one that gets generated does not work correctly I think it's missing a quote somewhere
git config --global alias.aliases '!git config --global --get-regexp alias.* | sed 's/\(alias\.[^ ]\+\) \(.*\)/git config --global \1 '\''\2'\''/''