FG
💻 Software

How can I push a Git repository to a folder over SSH?

Fresh5 days ago
Mar 15, 2026102866 views
Confidence Score1%
1%

Problem

I have a folder called my-project inside which I've done git init, git commit -a, etc. Now I want to push it to an empty folder at /mnt/foo/bar on a remote server. How can I do this? I did try, based on what I'd read: which didn't seem right (I'd assume source would come before destination) and it failed: I'd like this to work such that I don't have to access the remote host and manually init a Git repository every time ... do I have to do that? Am I going down the right route at all?

Error Output

cd my-project
git remote add origin ssh://user@host/mnt/foo/bar/my-project.git
git push origin master

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How can I push a Git repository to a folder over SSH?

Low Risk

The command is correct; however, the remote address must point to an initialized Git repository too. It's a one-time job, though. (In Git, a "bare" repository is one without a working tree.)

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment