mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 15:36:21 -04:00
35 lines
757 B
Bash
Executable file
35 lines
757 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
current_branch() {
|
|
git rev-parse --abbrev-ref HEAD
|
|
}
|
|
|
|
usage() {
|
|
echo "Usage: git merge-into [src] dest [--ff-only]"
|
|
}
|
|
|
|
cur_branch=$(current_branch)
|
|
if [ "${!#}" == '--ff-only' ]; then
|
|
case $# in
|
|
2 ) # dest --ff
|
|
git push "$(git rev-parse --show-toplevel)" "$cur_branch":"$1";;
|
|
3 )
|
|
git push "$(git rev-parse --show-toplevel)" "$1":"$2";;
|
|
* )
|
|
usage
|
|
esac
|
|
else
|
|
case $# in
|
|
1 )
|
|
git checkout "$1"
|
|
git merge "$cur_branch" "$1" && git checkout "$cur_branch"
|
|
;;
|
|
2 )
|
|
git checkout "$2"
|
|
git merge "$1" "$2" && git checkout "$cur_branch"
|
|
;;
|
|
* )
|
|
usage
|
|
esac
|
|
fi
|