Spyke
python·PythonbyYeahToast

synchronizing code between multiple work spaces

I'm a hobbyist and butcherer of python code. Quite often i'm jumping between multiple laptops / desktops playing around with different projects. Just wondering what the best workflow is or suggestions people have around syncing projects so I can edit and work on projects regardless of the computer. Is this something that people generally manage through github?? Thanks in advance for the thoughts!

View original on aussie.zone

Git is the way. I run a Gitea instance so all my code lives on my home server but have used Github in the past.

15

Perfect thank you. I haven't quite got a home server up and running yet, but am trying to keep things stored locally. Will look into it, thank you

2
lemmy.zip

yes, it is something people generally manage through git. github or gitlab (if you want to avoid microsoft)

10
lemmy.ml

Just use git and a remote repo. Don't need GitHub or anything of that sort.

8
programming.dev

Git. Git git git.
If it is text and can be modified from multiple places, should have a single "main" branch and feature work done independently on separate "branches". Or even just a "back this up".
Git.

Git is text based version control (tho it will do binary file, just not elegantly).

So yeh, git.
GitHub is easy to host on, but owned by Microsoft and is somewhat proprietary (by the time issues and other enhancements GitHub provides), but at the end of the day it is git with authentication and is on the ol "cloud".
Plenty of ways to replicate this if it's just for you

6

Thanks for your reply, I definitely have to look up the best practices for git storage / branches etc as I have no idea. Pretty keen to distance myself from Microsoft where able.

3
programming.dev

I don't think this has been mentioned, but it kind of depends on where your multiple laptops / desktops are. Is this always on your own home network? Because in that case you don't even need a remote service like Github

If so, you can create a network drive on any of the devices - mount the network device on your other devices, and then create a local git repo there. Just remember that using an external git service is also a backup. So if you do everything locally, make sure to have your own backups in place

A much, much worse but also possible solution is to just put your projects into onedrive/dropbox/gdrive and sync it everywhere. It works for syncing, since you're saying that's the main objective - but you lose out on version control

3

Thanks for your reply. I've started using tailscale so I think that could help re: remote access. An interesting thought about a shared network drive though.. I'm not yet at a point where I've got a server running 24/7 but I will be at some point (when RAM and storage stop killing me), which I think could be a good option outside of git

1
programming.dev

I'll add one more perspective: git is the "right" way to do it, but I'm a lazy forgetful person who wants to work on the laptop but the changes on the desktop aren't committed or pushed remote. What I often do is to use VScode's remote development tools to open a remote connection the last computer with uncommitted changes, and work like that. If I'm headed out, I'll use the remote connection to commit the code so I can access it off my home network via codeberg.org.

Occasionally if I'm already out, I've even used "raspberry pi connect" to remote onto my network, then ssh over to my desktop, then commit and push. Don't do that though. That'd be irresponsible.

3

Just set up wireguard and use that to connect to your home network when you're out.

2

Thanks for your reply . I've started using tail scale and rusk desktop for my remote access although I'm still fumbling through it.

1

code goes in git which you can push to other devices and pull from other devices. but if you're not used to it and you turn off a machine and forget to push... you're stuck.

for syncing files in general, I use syncthing. open source, e2e encrypted.

3

I use Mega(sync) to keep my various PCs in sync. Before that I used SpiderOak for a number of years, but the service started degrading at some point, which forced me to switch.

While committing to a git host is not a bad idea, it doesn’t cover all the stuff you might want to sync in my experience

2

Ah, haven't heard of that before. Thanks for your reply, I'll look into it :)

1

I used to use Dropbox for this, and it works, it's automatic, so you'll have the latest copy without manually pulling changes.

However, for any non-throwaway code i use git now. It gives me granular edit history via commits, branches for experimental changes, and i can push it to github where i can run tests and deployments for free. However if you're using git, you still need to run commit, push, pull commands but if you use an IDE or even a modern editor, it'll have hot keys for it already.

Also there are files you're not supposed to commit, like binaries and 3rd party dependencies so you may need to setup a virtualenv and run pip install on each machine independently.

1

One more thing regarding Git:

You'll likely want to keep your main branch functional at all times, so you would normally wait with your commit and push until a feature is ready. This wouldn't mix well with switching machines at random times.

That's where branches come in handy: create a feature branch, commit and push as often as you want. If the feature doesn't happen to work out, just delete the branch. When the feature is ready, merge the branch into the main branch. There even is an option to squash commits into a single one when merging, so you don't have to keep the whole commit history you created in the feature branch.

1

You reached the end