Ignore files that are ignored by git.#745
Conversation
This commit adds a new configuration option, similar to "sync hidden files". By default, any file that would be ignored by git is not synced. This introduces a dependency to libgit2. Related issue: nextcloud#26.
|
Thanks for your pull request @krobelus.
Can you describe the use case for this feature a bit more. I'm a bit concerned, that it is rather specific. I don't think that we should introduce such specific settings. cc @nextcloud/designers for the settings. |
|
Would it be a lot of work to teach the existing file exclusion system to handle gitignore's pattern formats? Then we could perhaps have a bit more generic "Import..." button to allow loading .gitignore or any other text files with a set of patterns? :) |
|
Files ignored by git should mostly be automatically generated, one may want to avoid uploading them. |
|
I'd also like to hear specific use-cases or user stories for this. Especially a new dependency is not to be taken lightly I guess? @rullzer @camilasan |
|
The use case here is syncing software projects without the overhead of syncing things like js/php/etc dependencies (which often include large amount of small files which are slow to sync). Having the client respect .gitignore files makes for an easy way of excluding all those files without any additional configuration. |
This comment has been minimized.
This comment has been minimized.
|
Would be fine by me, @rullzer @camilasan What do you think? |
|
would be amazing |
|
why just gitignore? I think this is a little bit too specific. Why not make it possible to simply ignore the paths inside of a given file? |
|
That would be a better option |
|
Please add this feature! |
|
Absolutely need this. I would personally be quite happy, with a more generic option, that states, if a file or folder exists inside of parent, ignore entire parent folder. As a parent-folder with a .gitignore file or .git folder inside, is usually distributed to other computers already, and sync'ed with git clone/pul/push, and I have no interest in having it automatically sync'ed across my various pc's (In fact, I would prefer it very much didn't !). I would point out, that ignore files, such as gitignore, don't simply contain paths, but patterns, so bes1002t suggestion of scanning files for paths wouldn't work. To my knowledge, gitignore set the standard for how ignores files tend to work, so the following filetypes use the same pattern, and might also be considered for inclusion... gitignore, npmignore, coffeelintignore, dockerignore, atomignore, vscodeignore, eslintignore, prettierignore, stylelintignore |
|
Might be hard to get right. An easy way to resolve this on the user's end is to only add the bare repository ( |
|
Although it doesn't solve the underlying issue (+1 for that, btw), you can skip the node_modules folder syncing by specifying the pattern "node_modules/" (without double quotes, with a slash at the end) in the client's ignore dialog. This may help you with your immediate problem. This feature would really come in handy for me because of cases such as:
I obviously can't just ignore most of these folders, as those names are pretty generic, and I would risk excluding relevant files. |
|
@krobelus @jsaraiva ie. "/home/user/projects/a-project/.git/" ends up ignoring "/home/user/projects/a-project" That being the case, I will stop polluting this thread, and simply state, that @krobelus idea gets a +1, would be awesome, from me. Edit: Escaped backslashes i regex |
|
I think this issue was in it's general ambition resolved by the great contribution of #1374 , am I right? Would be happy if you agree/disagree here to get this case closed and communicated 👍 🚀 |
|
@DominiqueFuchs yeah, that's a nice solution for the directory-specific excludes. |
|
Out of curiosity, do other users really want a working copy of a Git repository to be synchronized into Nextcloud server? Git and NC are both solutions for sharing and versioning files with servers and other clients, but for very different use cases. For me, if a Git working directory were in a NC-shared folder (a scenario I specifically avoid), then I would prefer that NC ignore the entire directory (not the one named I definitely understand the discussion to avoid build targets from synchronizing, but everything not a target is either scratch, which has limited long-term value, or source, which would, and certainly could, be replicated into a remote repository. |
|
@brainchild0 No, I would not want that, at all. |
|
@brainchild0 i use nextcloud as a sharing between my laptop and desktop. git projects are also synced in that folders. For me its just so the files are synced between my laptop and desktop and not for versioning. That is why i prefer that the excludes in the .gitignore are added to the nextcloud excludes. This because this are almost always library files and take up alot of space. |
|
For me it's the exact same issue: syncing between laptop and desktop... |
|
@Stijn98s @microtronics So you work on a development project alternating one system with the other, and you want your source files to be synchronized as soon as they change somewhere? I suppose your use case is not one I had not considered, as it is not how I normally work, but I understand the issue. Not to be pedantic, but NC synchronizes at the file level, and has the potential to introduce failures in a development project because of a tree state not representing a snapshot described by some atomic commit operation. It also lacks any facility for conflict resolution at the granularity below the file. You may be finding that you are having some success with using NC for your development projects, but have you considered just using a private working branch on a server? It could be even a different server from one you might share with your colleagues. It wouldn't be automated (unless you ran a background robot), but it would give you assurance that operations are atomic at the tree level. Once you are ready to merge into a shared branch you can rebase your history so no one sees your extra commits. |
This commit adds a new configuration option, similar to "sync hidden files".
By default, any file that would be ignored by git is not synced.
This introduces a dependency to libgit2.
Related issue: #26.
Some notes: