Mirror a Git Repository Through Ssh
Redmine can show the timeline of a Git repository but this repository needs to be local (see here). When you host your repository externally (on GitHub, for instance), you need to synchronize your remote repository on your Redmine server.
The following shell script is an All in one command that can be easily put in the crontab to mirror the repository on your Redmine server :
#!/bin/sh
if [ "run" != "$1" ]; then
exec ssh -i "$GIT_KEY" -o "StrictHostKeyChecking no" "$@"
fi
remote=$2
local=$3
echo "Mirroring from $remote to $local"
name=$(basename "$local")
export GIT_KEY="`mktemp /tmp/git.XXXXXX`"
export GIT_SSH="$0"
cat >"$GIT_KEY" <<EOF
-----BEGIN DSA PRIVATE KEY-----
### Put here your private key ###
-----END DSA PRIVATE KEY-----
EOF
if [ -d "$local" ]; then
git "--git-dir=$local" remote update
else
git clone --mirror "$remote" "$local"
fi
rm -f "$GIT_KEY"
exit 0
You need to copy the private key in the script (line 20). You can then use the script with the following syntax