-
-
Save quickshiftin/8809435 to your computer and use it in GitHub Desktop.
Checkout this approach for knowing what to transfer. This revision uses a local tag to track each time you use the command. The first time you use it, it pushes all files in the project. At the end of each run it updates the tag to point to HEAD. Next time you run it, it will only push files that have changed since the last push.
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
#!/usr/bin/env bash | |
# author: Thomas Aylott SubtleGradient.com | |
# author: Nathan Nobbe quickshiftin.com | |
# Find out where HEAD is pointing | |
head_ref=$(git show-ref --head -s | head -n 1) | |
# Check to see if transmit tag exists, and get transmit tag hash | |
_transmit_ref=$(git show-ref --verify -s refs/tags/transmit) | |
# If there's not transmit tag, create it for the first time. | |
if [ $? -gt 0 ]; then | |
# This won't work well for projects with multiple roots, | |
# but for the typical case it will find the first commit | |
# and tag that for the initial push. | |
first_commit=$(git rev-list --max-parents=0 HEAD) | |
echo 'Creating initial transmit tag' | |
git tag -m 'Creating transmit tag' transmit $first_commit | |
fi | |
# Find out where the tag is pointing | |
# @note Probably a cleaner way to do this ... | |
transmit_ref=$(git cat-file tag $_transmit_ref | head -n 1 | sed 's/^object //') | |
# If the transmit tag is the same commit as HEAD, | |
# there's nothing to do | |
if [ "$transmit_ref" == "$head_ref" ]; then | |
echo 'No changes to push' | |
exit 0 | |
fi | |
# Iterate over all the files that changed, adding then to Transmit | |
echo 'Transmitting' | |
for i in $(git diff --name-only transmit HEAD); do | |
if [[ -e "$i" ]]; then | |
echo "Adding $i to Transmit" | |
open -a Transmit "$i" | |
fi | |
done | |
# Update the tag so we know where the last push occurred | |
echo 'Updating transmit tag' | |
git tag -d transmit | |
git tag -m 'Updating transmit tag' transmit HEAD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Same problem as @reibejoy, solved using
/usr/local/sbin/
instead.