-
-
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 |
Can I in someway specify a commit for upload? Usually have to a site already up and running and I would rather not upload it again, only my minor changes.
@jannejava That's the whole idea behind this script. It will only push what has changed since the last time you pushed.
On OSX 10.11.2 this is what I get, trying to copy the file to /usr/sbin/ (btw: there's a typo in your cp line @quickshiftin)
sudo cp git-transmit /usr/sbin/
cp: /usr/sbin/git-transmit: Operation not permitted
Hi @reibejoy. It looks like need to use sudo
.
Same problem as @reibejoy, solved using /usr/local/sbin/
instead.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi guys, for the motivation to this gist, please see this StackOverflow thread. Essentially, these are the commands you need to follow to install the script: