Advertisement
voodooKobra

github-fork-sync.sh

Aug 22nd, 2014
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.51 KB | None | 0 0
  1. #!/bin/bash
  2. # Put this in ~/.bashrc for maximum ease
  3.  
  4. github_sync() {
  5.   if [ -z $1 ]; then
  6.     echo "Usage: github_sync branch_name"
  7.   else
  8.     upstream_exists=`git show-ref | grep upstream | wc -l`
  9.     if [[ $upstream_exists -eq 0 ]]; then
  10.       echo "There is no upstream branch. Make sure you run:"
  11.       echo "git remote add upstream https://github.com/___/___.git"
  12.     else
  13.       git fetch upstream $1
  14.       git checkout $1
  15.       git rebase upstream/$1
  16.       git push --force origin master
  17.     fi
  18.   fi
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement