Skip to content

Instantly share code, notes, and snippets.

@chr5tphr
Last active July 29, 2022 09:31
Show Gist options
  • Save chr5tphr/7df4a137597e9b62e56fd47dbb11bc06 to your computer and use it in GitHub Desktop.
Save chr5tphr/7df4a137597e9b62e56fd47dbb11bc06 to your computer and use it in GitHub Desktop.
Synchronize uncomitted changes
#!/bin/bash
RMTE="${1:?"No host supplied!"}"
RDIR="${2:?"No path supplied!"}"
REPO="${3:-"refs/heads/sync"}"
git push "${RMTE}:${RDIR}" "+@:${REPO}" && git diff HEAD | ssh "${RMTE}" \
"{ git -C '${RDIR}' reset --hard '${REPO}' && git -C '${RDIR}' apply --index - ; }"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment