Git Course 0%

Files and folders in a project

Beginner Core Git Git CLI VS Code UI IntelliJ UI ≈ 10 min

What you will learn

  • What the usual folders and files in a project are for
  • Which files are safe for you to edit, which need care, and which you must never edit by hand
  • How to see hidden files and folders in each tool

After this lesson you can

  • I can open any project and say what each top-level item is
  • I know where documentation, data and tests live and what a lock file is

Why this matters

You will spend your Git life inside project folders that someone else organized. Knowing the conventions tells you where to put a new document, which file to change to fix a typo, and, above all, which files to leave alone. Half of the "how did that get into my commit?" problems come from not knowing that a folder was generated.

The anatomy of a project

Most projects, in any language, look roughly like this. The playground follows the pattern:

trailguide/
trailguide/
├── README.md                 what this is, how to run it — the front door
├── CONTRIBUTING.md           the team's rules for contributing
├── .gitignore                files Git must never track
├── .gitlab-ci.yml            automated checks on GitLab
├── .github/workflows/ci.yml  the same for GitHub
├── docs/                     documentation (Markdown), images
├── data/                     data files the program reads
├── src/                      source code
├── tests/                    automated tests
└── .git/                     Git's history — never edit by hand
Anatomy of a project folder Three columns of files and folders. Green, edit freely: README, docs, data, CHANGELOG. Amber, edit with care: src, tests, configuration files, pipeline files, .gitignore. Red, never by hand: the .git folder, lock files, generated output such as build, dist, node_modules and __pycache__, virtual environments. EDIT FREELY documentation, data, notes README.md CONTRIBUTING.md CHANGELOG.md docs/ data/ your own scripts commit, open a merge request EDIT WITH CARE small, understood changes; run tests src/ tests/ pyproject.toml, package.json .gitlab-ci.yml .github/workflows/ .gitignore, .editorconfig ask a developer to review NEVER BY HAND Git's own data, generated files .git/ package-lock.json, poetry.lock build/, dist/, target/ node_modules/, .venv/ __pycache__/ .env (secrets) tools regenerate these; .gitignore hides most
Anatomy of a project folder: what each area is for and how freely you may edit it.
Item What it is for Typical names
README The first thing anyone reads: what the project is, how to run it, where the docs are README.md
Documentation Guides, references, decisions, in Markdown docs/, documentation/, wiki/
Source code The program itself src/, app/, lib/, or folders named after the language's habits
Tests Programs that check the program tests/, test/, spec/, __tests__/
Data Files the program reads, samples, fixtures data/, fixtures/, assets/
Configuration Settings for tools and the program: which Python version, how to lint, where to deploy pyproject.toml, package.json, .editorconfig, Dockerfile, *.yml
Dependency manifests and lock files The list of libraries the project needs, and the exact versions that were installed package.json + package-lock.json, requirements.txt, poetry.lock, Cargo.lock
Pipeline definitions What runs automatically after a push .gitlab-ci.yml, .github/workflows/
Generated output Files produced by a build or a tool; can always be regenerated build/, dist/, target/, out/, __pycache__/, node_modules/
Hidden folders Tool state, starting with a dot .git/, .venv/, .idea/, .vscode/
Licence and changelog Legal terms; a human-readable history of releases LICENSE, CHANGELOG.md

What you may touch

Think in three colours:

Colour Files Rule
Green: edit freely docs/, README.md, CHANGELOG.md, data files you own, your own scripts Edit, commit, open a merge request.
Amber: edit with care Source code, tests, configuration Small, understood changes only; run the tests; ask a developer to review.
Red: never by hand .git/, lock files, generated output, node_modules/, .venv/, anything listed in .gitignore Leave alone. If they appear in git status, something is wrong with .gitignore, not with you.

Hidden files

Files and folders whose names start with a dot are hidden by default on macOS and Linux. Several of the most important ones are hidden: .git (the whole history), .gitignore, .gitlab-ci.yml. Each tool has a way to show them.

ls hides dotfiles; ls -a shows all of them:

Terminal
$ ls -a
.
..
.git
.github
.gitignore
.gitlab-ci.yml
.markdownlint.json
CONTRIBUTING.md
README.md
data
docs
src
tests

. is the current folder and .. its parent; ignore them. On Windows, Git Bash behaves the same; PowerShell uses Get-ChildItem -Force.

Common mistakes

  • Committing generated output. build/ or __pycache__/ shows up in git status; you git add . and commit a thousand files. Prevention: check that .gitignore lists them (lesson 4.3).
  • Editing a lock file to "fix" a version conflict. It breaks installs for everyone. Ask the developer who owns the dependency.
  • Putting documentation next to the source. Most teams keep docs in docs/; a notes.md at the root of src/ will be moved or deleted. Look at where existing documentation lives and follow it.
  • Saving files in the wrong folder. Your editor's "Save as" may default to your home folder. Check that the file appears in the project tree before you look for it in git status.

Try it yourself

Goal: find every hidden item in the playground and classify each top-level item by colour.

  1. In a terminal inside trailguide, run ls -a.
  2. For each item, say green, amber or red before opening the solution.
  3. Open .gitignore in your editor and read the four groups of lines.

Expected result: you found .git, .github, .gitignore, .gitlab-ci.yml and .markdownlint.json, and .gitignore lists __pycache__/, .venv/, .env and editor folders.

Show solution

Green: README.md, CONTRIBUTING.md, docs/, data/. Amber: src/, tests/, .gitlab-ci.yml, .github/, .gitignore, .markdownlint.json (configuration: edit only when you know why). Red: .git/ and anything .gitignore names (__pycache__/, .venv/, .env, .idea/, .vscode/, .DS_Store).

Check yourself

1. git status lists a folder called node_modules/ with thousands of files. What is going on?
2. Where does the team expect a new "How to run the report" guide to live?
3. You cannot see the .git folder in VS Code's Explorer. What does that mean?

Key terms

Repository (repo) .gitignore Working tree