I am managing a website using git
. One of the requirements for the git repository
is that bare = true
. It uses a post-receive hook to manage pushes from my local computer. The problem is that sometimes I would like to make changes to a WordPress directory on my website using the wp-admin view online. So then I would just ssh
into the directory and run git --work-tree="BLAH" add .
and git --work-tree="BLAH" commit -m "BLAH"
. Is there a way to set up an alias, like alias git="git --work-tree=\"BLAH\""
and have that work for all git
commands?
In case anyone is curious how I solved it (thanks to shellter's comment), I wrote a bash script then prompted the user for input like so:
#!/bin/bash
function fix {
git --work-tree="PATH_TO_WORKING_TREE" $1
}
echo -n "git "
read -e INPUT
until [ "$INPUT" = "quit" ]; do
fix $INPUT
echo -n "git "
read -e INPUT
done
Running it:
user@server [repo.git] $ git-fix
git status
# On branch master
nothing to commit (working directory clean)
git quit