It is absolutely possible to do any merge, even non-fast forward merges, without git checkout
. The worktree
answer by @grego is a good hint. To expand on that:
cd local_repo
git worktree add _master_wt master
cd _master_wt
git pull origin master:master
git merge --no-ff -m "merging workbranch" my_work_branch
cd ..
git worktree remove _master_wt
You have now merged the local work branch to the local master
branch without switching your checkout.