1️⃣ Clone the repository
git clone https://github.com/USERNAME/REPO.git
cd REPO
This pulls everything that already exists in the repo.
2️⃣ Create or edit .gitignore
Create a .gitignore file (or open it if it already exists):
nano .gitignore
# or
code .gitignore
Example
.gitignore# Python__pycache__/*.pyc.venv/
# Logs*.log
# Env.env
# Builddist/build/
# OS.DS_StoreThumbs.db➡️ Important: .gitignore only affects future tracking, not files already tracked.3️⃣ Stop tracking files that are already in Git (KEEP them locally)
If files already exist in Git history, you must untrack them.
Untrack a file
git rm --cached path/to/fileUntrack a foldergit rm --cached -r path/to/folderex:git rm --cached -r .venvgit rm --cached .env✔ File stays on your machine
✔ Git stops tracking it
4️⃣ Commit the .gitignore and untracking changes
git statusgit add .git commit -m "Add .gitignore and stop tracking ignored files"git push origin main5️⃣ Verify ignored files
git status --ignored