DEV Community

Justin
Justin

Posted on

2

🔧 Using git with a local ssh server

Let's say you're ripping on a project and maybe have two computers at home or you don't feel like sharing the project you're working on to github/gitlab just yet.

You can use git + ssh to keep those two projects in sync and its super easy.

This is also a good way to work projects across computers without having to rsync or scp files.

Assuming you have a git project and a ssh connection already, you are pretty much all set. Just follow these instructions:

# on the remote server copy down what git you do have _or_
# create a new folder/git to sync it to
ssh user@host "git init --bare /mnt/foo/bar/my-project.git"

# then add that remote server
git remote add origin ssh://user@host/mnt/foo/bar/my-project.git

# and finally, push to it!
git push origin master
Enter fullscreen mode Exit fullscreen mode

Keep in mind, if you already have an origin, you can rename that to something like "local-server", then you have a "git push local-server" for local testing or "git push origin" for when its time to really deploy.

Happy coding!

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

đź‘‹ Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay