Improve remote git branch detection