+# Home, sweet home...
+# (We want to always switch back, in case we were on the base from failed
+# previous merge.)
+git checkout -q "$name"
+
+merge_with="refs/top-bases/$name"
+
+
+## Second, update our head with the remote branch
+
+if has_remote "$name"; then
+ rname="refs/remotes/$base_remote/$name"
+ if branch_contains "$name" "$rname"; then
+ info "The $name head is up-to-date wrt. its remote branch."
+ else
+ info "Reconciling remote branch updates with $name base..."
+ # *DETACH* our HEAD now!
+ git checkout -q "refs/top-bases/$name"
+ if ! git merge "$rname"; then
+ info "Oops, you will need to help me out here a bit."
+ info "Please commit merge resolution and call:"
+ info "git checkout $name && git merge <commitid>"
+ info "It is also safe to abort this operation using: git reset --hard $name"
+ exit 3
+ fi
+ # Go back but remember we want to merge with this, not base
+ merge_with="$(git rev-parse HEAD)"
+ git checkout -q "$name"
+ fi
+fi