I am currently on a debug branch, and would like to switch to the master branch, without modifying the working tree (leave it the way it is in the debug branch), so I can co
This answer uses low-level "plumbing" commands. Be careful. If you prefer "porcelain" commands, go with this answer which produces the same results.
You can reset your head to point at master without changing the index or working tree with:
git symbolic-ref HEAD refs/heads/master
You should probably reset the index so that you can selectively apply your working tree changes, otherwise you may end up committing all the differences between master and the debug branch, which is probably a bad thing.
git reset
Once you've made the commit that you want to make you can return to your debug branch with:
git symbolic-ref HEAD refs/heads/debug-branch
git reset