14 November 2026 · One command a day
How do I see where a git repository pushes to on Linux?
The git remote -v command lists every remote a repository knows about, and the URL it uses for each one. You reach for it when you land in a folder on a server and need to know where its code came from, and where a git push would send it. It only reads settings, so it is safe to run at any time.
I learn my automation tips in the AI Profit Boardroom. Have a look here. Affiliate link.
The command
cd /var/www/appname
git remote -vcd moves you into the repository, because git only reports on the repository you are standing in. git remote on its own prints just the remote names, such as origin. The -v flag stands for verbose. It adds the URL for each remote and shows it twice, once for fetching and once for pushing. No sudo is needed if your user owns the folder.
What you will see
origin git@example.com:user/appname.git (fetch)
origin git@example.com:user/appname.git (push)
backup https://example.com/user/appname-backup.git (fetch)
backup https://example.com/user/appname-backup.git (push)Each line has three parts: the remote name, the URL, and whether that URL is used for fetch or push. origin is the default name git gives the place you cloned from, so a plain git pull or git push uses it. A URL starting with git@ connects over SSH with a key. One starting with https:// uses a username and token. The fetch and push URLs are usually the same. If they differ, someone has set a separate push URL on purpose. If there is no output at all, the repository has no remotes, and its code exists only on this server.
When to use it
- You have taken over a server and want to know which repository each site folder belongs to before you change anything.
- A push fails with a permission error and you need to check whether the remote uses SSH or HTTPS, and which account it points at.
- You are about to push a fix and want to be sure it goes to the right repository, not an old fork or a backup copy. To see what you are about to send, list recent commits one line each.
Watch out for
Some repositories were cloned with a token written into the URL, such as https://user:token@example.com/user/appname.git. git remote -v prints that token in plain text, so do not paste its output into a chat, a ticket or a screenshot without checking it first. The token also sits in plain text in .git/config, where anyone who can read the folder can see it. Revoke the token, then switch the remote to a URL without it using git remote set-url.
Questions people ask
How do I change where a repository pushes to?
Run git remote set-url origin git@example.com:user/appname.git with the new URL, then run git remote -v again to confirm it.
Why do I get "fatal: not a git repository"?
You are not inside a repository folder, or the .git folder is somewhere higher up. Move into the project folder and try again. If git complains about dubious ownership instead, see running commands in a root-owned folder.
Checking and fixing where your own code is deployed from is the kind of thing you can only do on a server you control. You can get the same VPS with 20% off at https://asksteves.co.uk/vps. Affiliate link.
Want more automation tips? The AI Profit Boardroom on Skool is where I get mine. Have a look here. Affiliate link.
Everything on this blog runs on one Hostinger KVM 8. This link takes 20% off the same box.
Affiliate link.