In principal, if you use a git repository for your project you are always on a branch, so the first part of your question is confusing. Then, for the second statement, it should not be possible to lose code with git, you can retrace your commits to find the code back. But the confusing part of this part is that you make commits locally and push them to your remote branch. Then, lastly, to answer your question, depending on your environment/IDE, it is possible to stop committing by simply not committing. Since this is mostly a manual task.
I would have like to comment this (not enough points), since it is wise that you explain your situation a bit better and mention what IDE you're using and the branch and possible commits/commands you made.
About losing the code, you can revert your branch to a previous commit. If you stash your current changes you even not necessarily lose any of the code since that commit. Check the following thread:
How to revert Git repository to a previous commit?