Skip to content

Instantly share code, notes, and snippets.

@johnpapa
Last active November 6, 2020 19:32
Show Gist options
  • Save johnpapa/f3f100bfb383dc0531556380d968de0c to your computer and use it in GitHub Desktop.
Save johnpapa/f3f100bfb383dc0531556380d968de0c to your computer and use it in GitHub Desktop.
learn-sync
function learn-sync {
# ######################################
# What this does:
# ① Get the latest for your origin and upstream main branches'
# ② Make sure your main origin is in sync with your upstream and your local is pushed'
# ③ Checkout your branch for your Learn module and pull the latest'
# ④ Merge main with your Learn branch. This will sync your branch all changes in the upstream'
#
# Steps:
# 1. Navigate to your Learn repo (learn-pr, learn-m365-pr, etc)
# 2. Run `learn-sync <my-branch-name>`
# ######################################
local module_branch=${1:-};
local main_branch="${2:-master}";
echo ''
echo '① Get the latest for your origin and upstream main branches'
git checkout $main_branch
git pull upstream $main_branch
echo ''
echo '② Make sure your main origin is in sync with your upstream and your local is pushed'
git pull
git push
if [[ $module_branch == '' ]]
then
echo ''
echo '③ No branch specified, all done'
else
echo ''
echo '③ Checkout your branch for your Learn module and pull the latest'
git checkout $module_branch
git pull
echo ''
echo '④ Merge main with your Learn branch. This will sync your branch all changes in the upstream'
git merge $main_branch
git push
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment