For larger projects, it is often preferable not to insert all the code in one main file, but rather to split the contents into multiple files (e.g. chapters of a thesis). The overall project then consists of one main tex file and many sub-files.
These sub-files can be included in such a project on Overleaf by uploading them as attachments (via the files --> upload menu in the editor), and referenced in the usual way via
You can then edit these sub-files directly on Overleaf simply by clicking on them
To see a short video demonstrating this, see our blog post on writing your thesis with Overleaf.