mixing git and syncthing

For some directories, I like to only sync binary/non-plaintext files, I am using git right now for syncing my notes and it is very good for version control too, but bad for binaries as it save all the versions of big files.

I like to mix git and sycnthing for syncing so that best of the both words. but I think the config can be hard , as there are many plaintext types and bot .gitignore and .stignore only understand files by their name/extension not by mimetypes.

Any idea on how to do it. Or any other suggestion to solve my problem?

Hi @archie , I would use Syncthing for ALL sync instead of git. Use git for version control, which is where it really shines. IMO that would be using the right tool for each respective purpose.

And don’forget backup, because neither Syncthing nor git is a backup tool. I use restic.

1 Like

Hi @martinleben

I try to backup as much as I can. But I want to use git and syncthing for version control. How do you do it? Are you just put the whole directory that you use git on it under a stignore rule? I have some binary files in my git folders and I am not sure how to make a system to handle them. I just want to handle all plaintext files with git , and all the others with syncthing. because filter applied to them by extension not the mimetype it is a bit confusing for me how to implement it.

You would need to use some other way (e.g. a custom script) to create your .stignore patterns that would only cover a specific file type. Syncthing itself provides no such functionality.

I understand that, I was hoping someone had similar idea before me and I can get help from him on how to implement such a thing. Since git take a copy of every changing file, that causes .git folder to grow fast for binary files that changes. like a pdf file that get annotated and such

If you didn’t already, check if maybe git-lfs or git-annex is a better fit.

2 Likes

Yeah, I actually found out about it yesterday and looks like a good solution, but the thing is that I am hosting my own git and not sure how to set it up to use that and setup the location for managed files by lfs

Hmmm… I’ll still think you are making a mistake in mixing tools and their purposes. :slight_smile: This is how I see it:

  • Backup. I use restic. This is to where I look when I have screwed up and want to retrieve something I accidentally deleted, for example. Set it up and schedule it so that it does it’s stuff automatically. Once an hour, day, week or whatever you think is appropriate.
  • Sync. I use Syncthing to sync a number of folders (one each for documents, images, films etc) between devices, so that stuff which I regularly use on different devices is always “the latest” and in sync.
  • Version control. I use git for version control of stuff where history matters, like for scripts and different pieces of SW source code. I do NOT use git for “miscellaneous stuff” which I get the impression that you do, and frankly I think using it like that is a mistake, if I may say so. Some people use Syncthing for (parts of) version control, using it’s versioning feature. For this to “shine” I believe you need to enable versioning on a device you never use for your day-to-day work, because versioning does not handle local changes.

I hope this makes sense and good luck!

Yeah , Understand what you are saying here. I use restic for backup too, Altho I have to do it manually with attached storage instead of online.

My issue is that I want to mix syncing (between devices) with version controling. Syncthing is good at first , git is the best at the second. I want a bit of both. basically my issue is that the folderB that I want to version control (and sync between devices) its path is located inside a folderA that I just want to sync between devices. And also I have some binary files in folderB that I don’t like to keep differnet versions of them. I am just wondering that anyone else got into similar issue here, or it is just me that have this special problem. I think I just go wit git-lfs for folderB and sync the rest with sycnthing, maybe. I should learn more about git-lfs to see if that works , but looking for any solution people suggest here.

git-lfs is mature, tested it out a bit. Git like the filesystem is yet another “database”. Also I highly un-recommend syncing the .git “database” between machines. It does its own administration and packing. Better create a central git server/host or use public cloud git. But in your use case you want to upload (large) binary and quota can be an issue. And data safety in public cloud is also someone else his server infrastructure.

Hi again! :slight_smile:

I understand. And I believe that sometimes the best way to help someone is to say: “Don’t do that.”

I have recommended you to not do this, and people here and all over the internet agree. Basically you are on your own if you continue down this path.

I think that there is only one scenario where it is safe to sync a git repo: You actively use the repo on only ONE device (let’s call it “primary”) and never use the repo on any other device involved in the sync. The purpose of synching it would only be for redundancy in case your “primary” is lost.

If you don’t want to keep different versions of some files you need to ignore them in git. I suggest you read up on git in other places than here. :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.