Created
July 31, 2020 14:09
-
-
Save andreyfedoseev/6fb88ce7e895830c891e72aa14c16593 to your computer and use it in GitHub Desktop.
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 usage() { | |
cat >&2 <<EOF | |
Usage: $0 qa|dev | |
EOF | |
exit 1 | |
} | |
[ $# -lt 1 ] && usage | |
function git_current_branch () { | |
local ref | |
ref=$(command git symbolic-ref --quiet HEAD 2> /dev/null) | |
local ret=$? | |
if [[ $ret != 0 ]] | |
then | |
[[ $ret == 128 ]] && return | |
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return | |
fi | |
echo ${ref#refs/heads/} | |
} | |
branch=`git_current_branch` | |
if [ -z ${branch} ] | |
then | |
echo "Could not find the current git branch" | |
exit 1 | |
fi | |
base="$1" | |
aux_branch="merge-${base}/${branch}" | |
set -x | |
git fetch | |
if [ -z `git show-ref refs/heads/$aux_branch` ] | |
then | |
git branch --no-track "${aux_branch}" origin/${base} | |
git checkout "${aux_branch}" | |
else | |
git checkout "${aux_branch}" | |
git reset --hard origin/${base} | |
fi | |
git merge ${branch} --no-edit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment