local commit_new="$(git rev-parse origin/${branch})"
[ "${commit_old}" = "${commit_new}" ] && return 2
+ local current_branch="$(git rev-parse --abbrev-ref HEAD)"
+ if [ "${current_branch}" != "${branch}" ]; then
+ git checkout -b "${branch}" "${commit_new}"
+ fi
+
# Checkout the latest commit
git reset --hard "${commit_new}"