Dotfiles/site-modules/core/files/bin/git-merge-to
Ade Attwood 80239af169 refactor(core): start to make dotfiles public
This is the first commit that brings the privet dotfiles to a public
reop previously this was all one puppet module. Now this has been split
out so I can put all of the private files in a private puppet module
2020-09-20 06:22:17 +01:00

42 lines
662 B
Bash
Executable file

#!/usr/bin/env bash
#
# Merges a git branch into a another branch.
#
# Author: Ade Attwood <code@adeattwood.co.uk>
# Created: 2018-11-11
#
set -e
MERGE_BRANCH="$1";
main() {
local branch=$(git rev-parse --abbrev-ref HEAD);
echo "Merging $branch with $MERGE_BRANCH";
git checkout $MERGE_BRANCH;
git pull origin $MERGE_BRANCH
git merge --ff-only --log $branch;
}
if [[ ! -z "$1" ]]; then
main;
exit 0;
fi
cat << HELP
Git Merge To
For the reverse of \`git merge\`
The flow for the script is:
- Change to the target branch
- Pull branch for the latest changes
- Merge the previous branch
Usage: $0 <branch_name>
HELP
exit 1;