99# # then delete local and remote tracking branch
1010# #
1111# # @param $1 Branch to be merged
12+ # # @default current branch
1213# # @param $2 Branch to merge into
1314# # @default main
1415# # @param $3 Remote
1516# # @default origin
1617# ##############################################
1718ggit-merge () {
18- local branch=" ${1? : Source branch missing } "
19+ local branch=" ${1:- } "
1920 local into=" ${2:- main} "
2021 local remote=" ${3:- origin} "
2122
23+ [[ -z " ${branch} " ]] && branch=$( git rev-parse --abbrev-ref HEAD 2> /dev/null)
24+
2225 print-header Pull remote changes for " ${branch} " from " ${remote} "
2326 git checkout " ${branch} " || return 1
2427 git pull --stat " ${remote} " " ${branch} " || return 1
@@ -74,19 +77,22 @@ ggit-pull() {
7477# # Update local branch from remote
7578# #
7679# # @param $1 Branch
80+ # # @default current branch
7781# # @param $2 Remote
7882# # @default origin
7983# #################################
8084ggit-update () {
81- local branch=" ${1? : Branch missing } "
85+ local branch=" ${1:- } "
8286 local remote=" ${2:- origin} "
8387
88+ [[ -z " ${branch} " ]] && branch=$( git rev-parse --abbrev-ref HEAD 2> /dev/null)
89+
8490 print-header Fetch " ${remote} "
8591 git fetch --prune " ${remote} " || return 1
86- print-header Delete old " ${branch} "
92+ print-header Delete old branch: " ${branch} "
8793 git checkout -b " ${branch} -temp" " ${branch} " || return 1
8894 git branch -D " ${branch} " || return 1
89- print-header Checkout new " ${branch} " from " ${remote} "
95+ print-header Checkout new branch: " ${branch} " from " ${remote} "
9096 git checkout -b " ${branch} " --recurse-submodules --track " ${remote} /${branch} " || return 1
9197 git branch -D " ${branch} -temp"
9298}
@@ -105,17 +111,20 @@ ggit-diff() {
105111# # Rebase branch
106112# #
107113# # @param $1 Branch to rebase
114+ # # @default current branch
108115# # @param $2 Rebase onto this branch
109116# # @default main
110117# # @param $3 Remote
111118# # @default origin
112119# #######################################
113120ggit-base () {
114- local branch_src=(" ${1? : Branch to rebase missing } " )
121+ local branch_src=(" ${1:- } " )
115122 local branch_onto=" ${2:- main} "
116123 local remote=" ${3:- origin} "
117124 local branch
118125
126+ [[ -z " ${branch_src[*]} " ]] && branch_src=(" $( git rev-parse --abbrev-ref HEAD 2> /dev/null) " )
127+
119128 # If more than 3 arguments supplied
120129 # last 2 arguments are branch_onto and remote the rest are branch_src
121130 if [[ $# -gt 3 ]]; then
0 commit comments