When installing Git and Visual Studio Code, please refer to their official documentation to install it. I would recommend doing these rather than installing Ubuntu's snap packages as they tend to be slower in performance.
And of course, you are using Ubuntu which is Debian-based so installing a debian package should be great and smooth for you.
For Git:
https://git-scm.com/downloads/linux
#For the latest stable version for your release of Debian/Ubuntu
apt-get install git
# For Ubuntu, this PPA provides the latest stable upstream Git version
add-apt-repository ppa:git-core/ppa
apt update; apt install git
For Visual Studio Code:
Download the .deb (Debian, Ubuntu) under Linux category.
https://code.visualstudio.com/download
# After downloading it, install it using the following command
sudo apt install ./code-latest.deb
After doing all of these, it should be working out of the box now. Enjoy coding!