[Github importing] Automatically removes all files

Hey I am back again (This time not really JAVA based though)!

Each time when I import from GitHub all files get removed (which is understandable since it basically just replaces all files). The sad part is, I host a discord bot which must store certain data for users. For example if they are allowed to use certain commands + their permission level. Sadly I can’t do this easily, for example if I update the bot, it resets all data. Which is pretty unfortunate. How can I fix this? (The directory is called ‘storage’ which contains other directories with the id of the discord server where the data comes from).

Thanks for reading!

Hi! I can think of a couple options here:

1- make the changes you want to make to your bot in Glitch itself. The downside here is that since it auto-saves, you might have some downtime for your bot while you’re updating it.
2- use Git directly to merge in your changes from the Github repository, instead of using the import feature. You probably don’t want ‘storage/’ in Github or to overwrite it, so you can add that file to your .gitignore so it doesn’t get overwritten. You can use the console in your project to pull in changes from your Github project.

I can give more help on how to do 2 if you need it - this doc also has some commands you’ll likely want to use.

1 Like

Hey!

I am not really good with git itself, since I just started using it. Could you please help me with it? The part of pulling it to my glitch project and also, is it possible to host a database or some kind?

I just imported a repository from Github into a new project to test it out. I ran git remote -v to see what ‘remotes’ are configured. Remotes are like external places that your git repository knows how to connect to. Automatically, my project includes a remote called ‘origin’ that points to my original Github repository.

I made a change in my Test Repository on Github and committed it to the master branch. Then, in Glitch, I ran git pull origin master to bring that change from Github into my Glitch project.

git pull: “Fetch from and integrate with another repository or a local branch”. It can be used like this:

git pull [remote] [branch on the remote I want to pull into my current branch]

So, if you've been making changes on the branch called "my-feature", you'd call `git pull origin my-feature` in the Glitch console.

You might find when you run git remote -v that your Github URL is under a different name than origin. No problem! Just call git pull remote-name branch-on-remote-name with the values of remote-name and branch-on-remote-name set to the values that match your setup.


If this all sounds intimidating, you can do what I did and make a new repository on Github, import it into a new Glitch project, and test out your setup and the commands a few times before doing it in your bot project.

2 Likes

There’s one thing I forgot to mention - when you change files via the command line, the editor won’t show the changes to your files until you run refresh in the console - that forces the editor to make sure what’s showing in the editor matches what’s in the file system.

1 Like