Last active
April 30, 2017 21:07
-
-
Save techiev2/698b01c5bb0bc4c617a255ee07bbc6ef to your computer and use it in GitHub Desktop.
Helper script to fetch the latest changed remote and merge to master.
This file contains 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 | |
function getRemotes { | |
remotes=`git branch -r | grep -v HEAD` | |
local branches="" | |
for branch in $remotes; do | |
echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; | |
done | sort -r | head -n 1 | awk '{print $7}' | |
echo $branches | |
} | |
echo "Updating remotes" | |
out=`git remote update` | |
branch=$(getRemotes) | |
if [[ $branch == "origin"* ]]; then | |
echo "No remote changes. Skipping merge and deploy" | |
exit | |
fi | |
echo "Merging from $branch" | |
out=`git checkout master` | |
out=`git merge $branch` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment