Last active
December 30, 2015 14:39
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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