nextcloud / desktop

💻 Desktop sync client for Nextcloud
https://nextcloud.com/install/#install-clients
GNU General Public License v2.0
2.97k stars 784 forks source link

Add option to ignore git repos #4889

Open jonnykl opened 2 years ago

jonnykl commented 2 years ago

How to use GitHub

Feature description

I don't want to sync git repos. An option to ignore all git repos would solve this issue. There are multiple ways to implement this feature:

smihael commented 1 year ago

There is a script that essentially does this (https://gist.github.com/CodeArtha/abb4bd4209eea1df6e9ec9a219120fc6), but is not yet integrated. Downside of this kind of approach is that one has to clone repositories on all other machines manually.

In my typical workflow, I work on both code and on written materials such as papers and presentations. While Git is great for versioning code, it's less suitable for syncing larger (possibly binary) files. Contrarily, Nextcloud is a great self-hosted solution for synchronization and to a certain extend backup, but less suitable for version control.

Let's consider the following case. I want to sync a folder, e.g. Projects, between my laptop and a workstation in the office using Nextcloud. This folder contains multiple levels of sub-folders, that can contain documents or are git repositories.

I don't want to sync the contents of git repositories, as it can cause troubles if Nextcloud sync is triggered simultaneously with making commits. But as you can imagine, when the number of project grows, it becomes quite tedious to manually clone projects on all of the computers especially if they are located deep in the folder structure I'd like to have option to have git repository in any sub-folder (i.e. to have both git repository and some presentations under Projects/2023/example_repository/).

Rather than just ignoring all .git repositories, it would be better if just the references to the Git repositories would be synced. A possible (but probably too hacky) way to implement this would be to just sync the .git/config file (and exclude all others) in a directory. On other machines, one can then call git init to initialize git structure in that directory, and then use git pull to retrieve the contents of a remote repository (rather than cloning). Invoking git could be a feature for the desktop client and in the Nexcloud Web UI, one could be redirected to a web-interface associated with the git repository (if any).

bastian2001 commented 1 year ago

IMO the big problem with git repos is the many small files introduced by git. I think an even better approach would be to use .gitignore files and also just don't sync .git directories, rather than omitting the whole repo. If that's not desired, it would also be possible to make the exclusion list compatible with the gitignore syntax and just call the file somthing else, like .ncignore. I have a lot of problems with the sync exclusion list (files and directories being synced even though they are in the exclusion list, even after fully restarting the synchronisation), so that in my opinion something that is a more well-known standard like gitignore would be far superior and could also tackle individual folders instead of the whole synced directory with all subdirectories.

Oliver-Habersetzer commented 1 year ago

I downloaded the sourcecode and I'll try to integrate this.

My idea was also to call

git init
git remote add origin <remote_url>

That way a user can interact with the git repository as they're used to.

I just worry about branches: if you have unsaved changes on two PCs in different branches, we might get oscillating behavior that'd likely break the git repo. I'll have to test it a bunch.

mlasch commented 9 months ago

An option like "Sync git repositories", which can be disabled, would be very helpful to exclude the whole Git workspace. Git uses its own mechanism to sync files over the network with other machines.

Working with Git, or a similar version control system, inside a synced directory reacts on Git operations like branch checkouts and would trigger updates on all other machines altering the working environment.

With such a "Sync git repositories" or a more general "Sync SVC repositories" option Git could be used independently inside a synced Nextcloud directory.

joshtrichards commented 3 weeks ago

Is there a reason the existing Ignored Files feature can't be used to accomplish this?

smihael commented 3 weeks ago

Yes, there is a reason. Last time I checked, there was nowhere to set files excluded from the ignore pattern. I want to exclude the content of any git repositories, except for the . git/config file.

On Sat, 17 Aug 2024, 08:12 Josh, @.***> wrote:

Is there a reason the existing Ignored Files feature can't be used to accomplish this?

— Reply to this email directly, view it on GitHub https://github.com/nextcloud/desktop/issues/4889#issuecomment-2294472960, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAP6BIUXSFWRG6HTUKBQBZTZR2IPXAVCNFSM6AAAAABMU4KJ2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJUGQ3TEOJWGA . You are receiving this because you commented.Message ID: @.***>

mlasch commented 3 weeks ago

Is there a reason the existing Ignored Files feature can't be used to accomplish this?

I don't think you can't accomplish this with just the Ignored Files. While it is possible to ignore the .git directory in a checked out repository, as far as I can tell, it is not possible to "ignore a whole directory which contains a .git". The reason is not only the .git should be ignored, but all files under version control.

This might go even further to still sync .git/config as mentioned by @smihael as well as "untracked files". But a basic "Don't sync git repositories" would be already a big step.