Sublime Forum

Sublime Merge - exclude files (not related to .gitignore) - Git

#1

There are files in my repo which are not, and cannot be “gitignored”.
However, I need sublime merge to ignore these.
Is there a way to set this up.

I tried using “file_exclude_patterns” in the settings file and the files are still showing up in Sublimerge.

0 Likes

#2

You may try running on the command line the command git update-index --assume-unchanged file1.txt and see how Sublime Merge behaves. It still showing the files for you?

Update:

Sorry I just realized that the --assume-unchanged command is only available for files already tracked by git.

0 Likes

#3

This is what I had :

"file_exclude_patterns":
    [
    "tpl.js"
    ]

}

I also tried “*.tpl.js” with no success.

0 Likes

#4

Ok will try… but this will introduce a manual step each time. These files are automatically generated files from a template. So the files need to be deployed / tracked by git, but since they are auto-generated I never need to peek into them to see what changed in the last commit.

0 Likes

#5

I’m curious as to why/how you have files that need to be ignored but cannot be added to .gitignore?

0 Likes

#6

These files need to be present because they are source code.
These files need to be ignored (by humans) because they are generated source code.

I use Handlebars.js. This templating library has 2 extensions, “*.tpl” is what I edit, to change or create templates. There is a preprocessor that takes this .tpl template and generates a .tpl.js file (which is like machine generated code, quite unreadable - like a minfied Javascript file). I want to keep the “.tpl.js” machine generated file present in the repo, but when browsing for changes I want to ignore them.

That’s the reason I want to ignore certain files, which need to be present physically. Hope that clarifies.

0 Likes

#7

Well all my files are tracked (and need to be tracked) by git. These are machine-generated javascript files (There is a node package called Handlebars.js - which creates these machine-generated JS files - which by definition look highly unreadable , like minified javascript).

I want to ignore (human ignore, as opposed to git-ignore) the machine-generated stuff - in other words, these files which have the extension “.tpl.js” very much need to be there (because I cannot regenerate them at the time of deployment to the webserver (inconvenience of various kinds) - they’re almost like binary files, like a minified JavaScript file).

To put it another simpler way : Lets say I have a JS library (code that I wrote), and when deploying to the server, only the minified version needs to be deployed. In this scenario, the minified file is never browsed/reviewed for code changes on the development machine, but circumstances dictate that it be physically present in the repo (or else when deploying the rep on the web server it wont get copied over).

0 Likes

#8

Purely out of curiosity, do you have a workflow or process in place (like a pre commit hook) that makes sure that these files are committed to the repository alongside the source file changes that caused them to be regenerated? If git (or Merge specifically) was ignoring files that are tracked and should be committed, I would be paranoid that I would forget to add them to a commit because I have the memory of a bowl of jello.

1 Like

#9

Then, you can definitely ignore them with git update-index --assume-unchanged

According to the documentation, https://git-scm.com/docs/git-update-index It does not accept glob patterns. Then, you could write a shell script which you run git update-index --assume-unchanged on each target file when you have your repository with these files on dirt state.

1 Like