Long hair and Jiu-Jitsu don’t always go well together. If you don’t want any hair troubles, while rolling, the best is to have the most popular haircut in BJJ: the shaved head (minus the cauliflower ear):
If you have longer hair, you can do what Cris Cyborg does but that may be a bit too time consuming:
BJJ Blue Belt Mikaela Mella shows some great tips on how to tie your hair for BJJ competition: