this post was submitted on 25 Oct 2024
24 points (96.2% liked)

Programming

17443 readers
162 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS
 

Hi programmers,

I work from two computers: a desktop and laptop. I often interrupt my work on one computer and continue on the other, where I don't have access to uncommitted progress on the first computer. Frustrating!

Potential solution: using git to auto save progress.

I'm posting this to get feedback. Maybe I'm missing something and this is over complicated?

Here is how it could work:

Creating and managing the separate branch

Alias git commands (such as git checkout), such that I am always on a branch called "[branch]-autosave" where [branch] is the branch I intend to be on, and the autosave branch always branches from it. If the branch doesn't exist, it is always created.

handling commits

Whenever I commit, the auto save branch would be squashed and merged with the underlying branch.

autosave functionality

I use neovim as my editor, but this could work for other editors.

I will write an editor hook that will always pull the latest from the autosave branch before opening a file.

Another hook will always commit and push to origin upon the file being saved from the editor.

This way, when I get on any of my devices, it will sync the changes pushed from the other device automatically.

Please share your thoughts.

you are viewing a single comment's thread
view the rest of the comments
[–] drew_belloc@programming.dev 1 points 3 weeks ago (1 children)

You could also use syncthing so when you are conected to your lan you work folder will always be synced from one pc to another, that way you won't have a bunch useless commits on git and you can still commit and push the changes from any computer

[–] matcha_addict@lemy.lol 1 points 3 weeks ago (1 children)

When I looked into solutions, I thought of syncthing, but read comments from people saying they had issues with this approach, especially regarding the .git directory

[–] SaveMotherEarthEDF@lemmy.world 1 points 3 weeks ago* (last edited 3 weeks ago)

Sorry what issues? I'm using syncthing to sync between a macos laptop, a macos vm, and my main linux desktop. I sync my projects folder with a lot of git repos. Maybe I've been lucky so far but no issues with syncthing and git so far

It's really like magic sometimes