How to install git

How may I fix this error?
You must install Git before installing Homebrew.
I have installed Xcode and command line tools but does not work...

Ensure that the command line tools are active. Check in Xcode's Preferences > Locations panel, there is a drop-down to select the currently active set of command line tools, in case you have multiple sets of command line tools installed.
How to install git
 
 
Q