E: Unable to locate package git

You can add manually repository

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E1DD270288B4E6030699E45FA1715D88E1DF1F24
sudo su -c "echo 'deb http://ppa.launchpad.net/git-core/ppa/ubuntu trusty main' > /etc/apt/sources.list.d/git.list"

sudo apt-get update 
sudo apt-get install git

I got this error after spinning up a Debian instance on DigitalOcean. The fix was to

sudo apt update

when you install Ubuntu package off-line usually in first of installation its cache doesn't get update so this error will occur and you have in your Ubuntu broken packages . for solution type in Terminal:

sudo apt-get install -f

it will repair broken packages and after it you can continue.