Skip to content

Instantly share code, notes, and snippets.

@nicerobot
Last active December 30, 2015 14:39
Show Gist options
  • Select an option

  • Save nicerobot/7843781 to your computer and use it in GitHub Desktop.

Select an option

Save nicerobot/7843781 to your computer and use it in GitHub Desktop.
rsync the working directory to a directory under ~/.forwardgit/ then run the git command in that directory.
#!/bin/bash
# Simply wraps git to rsync the current folder under ~/.forwardgit/ then
# runs the git command in that folder.
# The reason: https://plus.google.com/+nicerobot/posts/YDAaKbaiGRw
# TODO try this with gin https://github.com/nicerobot/gin
# set -x
FGITD=${HOME}/.forwardgit
DESTD=${FGITD}/$(basename ${PWD})
[ -d ${DESTD} ] || {
mkdir -p ${DESTD}
}
# If there's no .gitignore, but there is a .forwardgit script with an ignore variable,
# use the ignore value as the parameter to gitignore.io.
[ ! -f .gitignore -a -f .forwardgit ] && (
source .forwardgit
[ "${ignore}" ] && {
curl http://gitignore.io/api/${ignore} > .gitignore
}
)
rsync -vazu --delete --exclude .git . ${DESTD}/
cd ${DESTD} || exit ${LINENO}
git ${@}
exit ${?}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment