Is it possible to do the following things on the same git directory simultaneously:
compiling on one branch
working on another branch
You can use additional worktrees for this. One worktree can be checked out on a branch, with its own directory, where you do your compiling.
And the other worktree can be checked out on another branch, in a distinct directory, for you to keep on working without interfering with the compiling going on in the other one.
Check the doc here.
Typically :
git worktree add <path/to/new/worktree>
then cd
between your directories to execute commands on either worktree.