I am new to Ubuntu and want to do sudo apt install git.
Do I need to be in root directory or in my home directory for that?
You don't need to be in any specific directory to call this command. You can see this by calling
sudo apt-file update
apt-file list git
which lists all files that would be installed as part of git package. Note that the output is irrelevant to your current location (i.e. these files have absolute location).