Skip to content

Instantly share code, notes, and snippets.

@dflima
Created August 30, 2016 10:48
Show Gist options
  • Save dflima/98d12282bb3357fa1564cd499c5e0fa1 to your computer and use it in GitHub Desktop.
Save dflima/98d12282bb3357fa1564cd499c5e0fa1 to your computer and use it in GitHub Desktop.
Checkout to a base branch (master, develop etc.) and merges to your current branch
#!/bin/bash
function usage()
{
printf "Usage:\n\n"
printf "./merge_branches.sh <branch>\n\n"
}
if [ "$1" == "" ]; then
usage
exit 0
fi
source_branch="$(git branch | grep \* | cut -d ' ' -f2)"
dest_branch=$1
git checkout $dest_branch;
git pull -p;
git checkout $source_branch;
git merge $dest_branch --no-ff;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment