Last active
May 19, 2017 18:11
-
-
Save eddiemoya/ad4285b2d8a6bdabf432 to your computer and use it in GitHub Desktop.
Fast forward merges one branch into another without having to checkout either - fails if the second parameter is not fast-forwardable.
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 | |
# usage: | |
# git-merge-ff-only.sh master develop | |
# Will only merge develop into master if its fast-forwardable. | |
merge_into=$1; | |
merge_from=$2; | |
git merge-base --is-ancestor $merge_into $merge_from; | |
is_ffable=$? | |
if [ $is_ffable == 0 ]; then | |
git update-ref refs/heads/$merge_into $merge_from; | |
echo "[$merge_from] has been fast-forward merged into [$merg_into]"; | |
else | |
echo "[$merge_from] can NOT be fast-forward merged into [$merged_into]"; | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment