Optional
Gitignore
Use .gitignore to keep generated files, local caches, and machine-specific clutter out of GitHub.
Ignore local clutter
You can create a .gitignore file to exclude specific files or folders from your GitHub commits.
This is also useful for large files, such as datasets or generated outputs, that are too large to upload to GitHub and should stay on your computer.
Let's assume you want to ignore all contents within the heavy folder.
Create a .gitignore file in the root folder.
Add the folder name or ignore pattern to .gitignore so Git knows that this path should stay local.
After you save the file, you will then see that the folder is grayed out.
Commit and push the project after saving the ignore rule.
After you commit and push, you will see that the ignored files have not been uploaded to GitHub, but the .gitignore file itself has been uploaded.
Already uploaded clutter files
.gitignore works only on untracked files. It ignores neither staged nor committed files. You need to remove already tracked files from the cache to apply .gitignore.
If you want to remove an already uploaded file or folder from GitHub while keeping it on your computer, enter the following command in the terminal.
git rm -r --cached <file-or-folder-name>
git commit -m "Stop tracking ignored files"
git push
Check that the files or folders you want to exclude are listed in .gitignore, grayed out in VS Code, and absent from GitHub after commit and push. If a file still appears in Git, confirm whether it was already tracked before the ignore rule was added.