mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
add merge-into to merge two branches quickly
This commit is contained in:
parent
d690268b43
commit
d94663312f
34
bin/git-merge-into
Executable file
34
bin/git-merge-into
Executable file
|
|
@ -0,0 +1,34 @@
|
|||
#!/bin/bash
|
||||
|
||||
current_branch() {
|
||||
git rev-parse --abbrev-ref HEAD
|
||||
}
|
||||
|
||||
usage() {
|
||||
echo "Usage: git merge-into [src] dest [--ff]"
|
||||
}
|
||||
|
||||
cur_branch=$(current_branch)
|
||||
if [ "${!#}" == '--ff' ]; 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
|
||||
Loading…
Reference in a new issue