Last active
January 16, 2017 18:17
-
-
Save Sanne/8d4752322b1c9f1d6af03cec3597d943 to your computer and use it in GitHub Desktop.
git-update
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 | |
# Temporarily checks out the "master" branch, fetches updates from upstream, | |
# pushes a copy to "origin" to keep it in synch, and then returns to the original | |
# branch. | |
# | |
# Released under the WTFPL license version 2 http://sam.zoy.org/wtfpl/ | |
# | |
# Copyright (c) 2014 Sanne Grinovero | |
requireBranchName() { | |
branch_name="$(git symbolic-ref HEAD 2>/dev/null)" | |
if [ "$?" -eq 128 ] | |
then | |
echo "Current branch not defined - aborting" | |
exit -1 | |
fi | |
branch_name=${branch_name##refs/heads/} | |
} | |
requireBranchName | |
git fetch upstream | |
git checkout -q master | |
git pull --ff-only upstream master | |
git push origin master | |
git checkout -q ${branch_name} | |
echo "Master updated" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment