Is it safde to put editor/ in Gitignore?

I’m working with team and after migrating to Godot 4 there is alot of .cfg files in git that looks useless. most of them from editor folder. Ss I understand this files saving which folders and files was opened in editor.

Am I right about purpose of this files?
Is it safe, to put editor/ in gitignore?

The Files to Exclude from VCS page in the manual goes over .gitignore and some other things. You’re probably right about the purpose of the files, and yes they should have originally been ignored by git since the editor folder is onder the .godot folder.

However, if any files within the .godot folder have already been committed to the repository, then the .gitignore will only help prevent committing further files (.gitignore only matters for files that are not yet tracked by the repository). So if that is the case, the problem has become one of repository history rather than .gitignore.

There is a way to tell git to disregard changes to certain files in the working tree, but it can run into issues that force you to undo that measure temporarily.

The better long-term fix is to instead create a new repository with a proper .gitignore in place so that those files are never committed. If your group does not care about the commit history, you could simply start a new blank repository, copy the current code in, do the big initial commit, and continue from there. If you want to retain commit history other than these files, there are ways with git on the cli to rewrite the history into a new repository while ignoring any information about those files - so there’d be some learning overhead with git’s manual to work that out.

2 Likes

If you have files that are commited before you add them to the .gitignore they wont be ignored (changes will still be picked up by git). But you don’t need to make a new repository to fix it.

to remove a file from the git repository without removing the copy from your current directory use:

git rm --cached file
# or
git rm --cached -r folder

BIG NOTE this doesn’t delete the file(s) from your local filesystem, but git will remove them when other people get the changes from git to remove those files from the repository. It does this in a safe way just like any tracked file but it’s a good thing to keep in mind. Once someone has the change on their local history it will stop trying to remove it, so going forward it will be the same as if it was never committed (unless you checkout those old commits)

So if you committed files in the .godot folder and then added it to the .gitignore later, you would want to do

git rm --cached -r .godot/
git commit -m "Removed .godot folder from tracking"

git will now ignore changes to the files that were already commited inside .godot/ going forward.

(since .godot/ is all generated and can be recreated, you could also just delete the whole folder and then commit that to git, but this is the general solution for when you may care about the current version of the file)

2 Likes

Well I’m certainly happy to learn a simpler solution today, too. I have a repository at work to try this on.

2 Likes

Hey there, I tried this and it seemed to work! However, when I tried this my DEBUG window when I run the game is now blank (previously had scene and a figure I could move around). I did all the steps cammymoop stated. I’m wondering if I have to also delete the godot folder on my computer to be regenerated?

The debugger log also looks as follows (when godot is loaded up):
— Debugging process stopped —
Cannot save editor settings to file ‘res://.godot/editor/project_metadata.cfg’.
Cannot save editor settings to file ‘res://.godot/editor/project_metadata.cfg’.

Think the error lies in the fact the editor folder is no longer on my PC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.