Import from github and skip single file

Heya folks!

I am trying to do a dev / production style workflow, so I have 2 projects:


&

This is working out great, I can dev without disturbing the “real” project, and use github export + import to move from dev to live.

The problem is that I am using a flat file as a database for the project, but it is getting overwritten when I import from github. I want to keep that file around when I do the import.
There is this old topic that marked .env as not overwriteble: Keep .env when importing from GitHub? - but if possible, I would like to mark a whole folder, or an arbitrary file as not overwriteable.

Hi @jonbro

What you’re looking to do should be built into Glitch already - you might get a little more benefit from perusing https://glitch.com/help/env/ in addition to any relevant forum topics, but the essence is that we provide the .data folder for exactly this purpose. Any file or folder you include in a .gitignore file should be protected from this sort of overwriting, but .env and .data are already ignored in your project’s global gitignore configuration.

Hope this helps, and happy Glitching!

1 Like

ah ha! I should have dug into the docs more :slight_smile: sorry about that, and thanks very much!

Sorry but the .data folder didn’t help keep the files inside when I import changes from my repo.

What I did:

  • Created this file .data/users.db. (btw I don’t see any option for create a new folder so I just write it that way in the field of the name of the new file)
  • Import changes from github into my glitch project

My expectation: Kepp the .data folder and then bring in the other files from my repo
Reality: The .data folder and its files disappear and the new files remain. (but .env doesn’t disappear though)

Hi @Rotimi_Best, the “Import from Github” is intended to overwrite your project, but it should leave alone files that are gitignored, including those ignored by the container’s global gitignore (which includes .env and .data/*).

In my brief testing, both my .env file and the contents of .data are left alone by the import process. If you’re seeing something different can you provide the name of your project so we can take a look?

My project is telegram-bot-boilerplate.

Ok, I remixed your project, recreated the .data/users.js file, and imported from one of my GitHub repos and I saw the expected behavior - that is to say my new .env file was left alone and .data/users.js is just as I left it, but everything else was overwritten with my repo’s data.

Are you able to reproduce this with your project and repo, and if so can you provide a link toi the repo as well?

Yes I am able to. I think I get it now, this is what I did:

  1. Imported from repo without .data/cool-file.js.
  2. Created file (or folder with file) .data/cool-file.js.
  3. Required in index.js (Everything works well).
  4. Imported from repo again without .data/cool-file.js
  5. Folder disappears (I don’t see it in my file tree).
  6. (But strangely) I require the file again in index.js and everything still works well.

So it actually works but I don’t get why I can’t be able to see my .data/* directory.

Aha, that’s actually a feature!

With few exceptions gitignored files (and anything under .data is gitignored by your project’s global gitignore file at /etc/gitignore-global) are also hidden from the editor, so it’s expected that your .data/cool-file.js file wouldn’t be visible in the file tree. The editor and the file system aren’t in perfect sync, so sometimes an ignored file will stay visible until the project restarts (which the git import process will do).

This also explains why requiing the file still works. It’s there; just not visible in the editor.

Hope this helps. Happy Glitching!

1 Like

:grinning::grinning: Perfect then.

Thanks

This got me confused at first but thanks for the clarification, it makes sense. :+1::+1:

Also in another project of mine I had some files creds.json and tokens.json. I added them to the project by uploading them and pulled latest changes from my repo (Those files were already added to my.gitignore to ignore them) and after the pull the files disappeared. I noticed that my app didn’t crash, and it worked as though those files were there (I would have gotten some errors if they weren’t there).

Does that mean those files are there but I can’t see them in the editor?

Yes! Another instance of the same effect! Since those files are gitignored (and thus protected from the GitHub import) they’re also hidden from the editor when the project restarts.

1 Like