if [ "$new_branch" = 'master' ]; then
old_branch=$(git branch --show-current)
if ! [ "$old_branch" = 'master' ]; then
- if ! cd ../next; then
- fix_up 'no ../next directory!'
+ if ! git checkout master; then
+ fix_up 'git checkout master failed'
fi
- git worktree remove "$old_branch"
fi
else
base=${branch#"$new_branch"/}
- if ! git worktree add -B "$new_branch" ../"$new_branch" "$base"; then
- fix_up 'git worktree add failed'
- fi
- if ! cd ../"$new_branch"; then
- fix_up 'cannot chdir to new worktree directory'
+ if ! git checkout -B "$new_branch" "$base"; then
+ fix_up "git checkout $new_branch failed"
fi
fi
continue