@@ -136,24 +136,14 @@ if [ $failed -eq 1 ]; then
136136 exit 1
137137fi
138138
139- # Reset source branch to source base
140- zz_log i " Resetting '$source ' to source base"
141- if ! git reset --hard $source ; then
142- zz_log e " Failed to reset '$source ' branch"
143- exit 1
144- fi
145-
146139# Fast-forward target branch
147140zz_log i " Fast-forwarding '$target ' branch"
148141if ! git checkout " $target " ; then
149142 zz_log e " Failed to checkout '$target ' branch"
150143 exit 1
151- elif [ -n " $push " ]; then
152- zz_log i " Pushing changes to remote"
153- if ! git push origin " $target " ; then
154- zz_log e " Failed to push '$target ' branch to remote"
155- exit 1
156- fi
144+ elif [ -n " $push " ] && ! git push origin " $target " ; then
145+ zz_log e " Failed to push '$target ' branch to remote"
146+ exit 1
157147fi
158148
159149if ! git merge --ff-only " $temp " ; then
@@ -167,5 +157,22 @@ else
167157 git branch -D " $temp "
168158fi
169159
160+ # Reset source branch to source base
161+ zz_log i " Resetting '$source ' to source base"
162+ if ! git checkout " $source " ; then
163+ zz_log e " Failed to checkout '$source ' branch"
164+ exit 1
165+ elif ! git reset --hard " $base " ; then
166+ zz_log e " Failed to reset '$source ' branch"
167+ exit 1
168+ fi
169+
170+ # Go back to original branch
171+ zz_log i " Switching back to original branch '$current '"
172+ if ! git checkout " $current " ; then
173+ zz_log e " Failed to checkout original branch '$current '"
174+ exit 1
175+ fi
176+
170177# Log success message
171178zz_log i " Successfully moved commits from '$source ' to '$target '"
0 commit comments