Installing git is fairly straightforward, but varies from Operating System to Operating System.
Current Linuxes all have git in the main repositories.
apt-get install git
yum install git
zypper install git
If that doesn't work, you may need to try installing git-core instead, but honestly, if that's the case, you should probably update to a more recent linux.
Your best bet is to make sure that you are on the latest release of OSX and then Install Xcode from the App Store. Xcode bundles git so you'll be good to go.
Another alternative, such as if you are running on an older OSX and cannot, for some reason, upgrade, is to ensure that the right Xcode is installed for your system, then Install homebrew Once that's done:
brew install git
should have you off to the races