<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Azhar Alvi </title>
    <description>The latest articles on DEV Community by Azhar Alvi  (@silentcarry).</description>
    <link>https://dev.to/silentcarry</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4032488%2F41bd09e7-acef-435e-8ec5-5d489ca389d1.gif</url>
      <title>DEV Community: Azhar Alvi </title>
      <link>https://dev.to/silentcarry</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/silentcarry"/>
    <language>en</language>
    <item>
      <title>Phase 0 : Building My First FastAPI App: Setup, Git, and Secrets Done Right</title>
      <dc:creator>Azhar Alvi </dc:creator>
      <pubDate>Thu, 16 Jul 2026 18:57:38 +0000</pubDate>
      <link>https://dev.to/silentcarry/phase-0-building-my-first-fastapi-app-setup-git-and-secrets-done-right-38m6</link>
      <guid>https://dev.to/silentcarry/phase-0-building-my-first-fastapi-app-setup-git-and-secrets-done-right-38m6</guid>
      <description>&lt;p&gt;&lt;strong&gt;Tagline: Commit small, commit often, write real messages.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Creating a hello-world app sounds easy — and it is. But doing it &lt;em&gt;the right way&lt;/em&gt;, with proper git hygiene, isolated environments, and secrets handled safely from day one? That takes a bit more care. Here's what I actually did, step by step, and why.&lt;/p&gt;

&lt;h2&gt;
  
  
  Index
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Introduction&lt;/li&gt;
&lt;li&gt;Structure of this log&lt;/li&gt;
&lt;li&gt;
Step 1: Project Foundations

&lt;ul&gt;
&lt;li&gt;Create the folder&lt;/li&gt;
&lt;li&gt;Initialize git first&lt;/li&gt;
&lt;li&gt;Create &lt;code&gt;.gitignore&lt;/code&gt; before installing anything&lt;/li&gt;
&lt;li&gt;Create and activate the virtual environment&lt;/li&gt;
&lt;li&gt;Install packages + freeze requirements&lt;/li&gt;
&lt;li&gt;First commit&lt;/li&gt;
&lt;li&gt;Connect to GitHub&lt;/li&gt;
&lt;li&gt;The repeatable loop&lt;/li&gt;
&lt;li&gt;The commit flow, in isolation&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
Step 2: Getting FastAPI Running Locally

&lt;ul&gt;
&lt;li&gt;Ensure the virtual environment is active&lt;/li&gt;
&lt;li&gt;Install FastAPI and Uvicorn&lt;/li&gt;
&lt;li&gt;Create the app file&lt;/li&gt;
&lt;li&gt;Start the server&lt;/li&gt;
&lt;li&gt;Check the automatic docs&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
Step 3: Secrets — the &lt;code&gt;.env&lt;/code&gt; File

&lt;ul&gt;
&lt;li&gt;Create &lt;code&gt;.env&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Confirm it's actually ignored&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Step 4: Start This Build Log&lt;/li&gt;
&lt;li&gt;Key Habits to Keep&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;I started learning backend dev properly this week, and today I got a hello-world FastAPI app running locally. Nothing fancy — one route, one JSON response — but I wanted to write down what actually happened along the way, because "install a package and run a command" always looks simpler in hindsight than it feels in the moment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Structure of this log
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Create project folder → init git → &lt;code&gt;.gitignore&lt;/code&gt; → virtual environment&lt;/li&gt;
&lt;li&gt;Connect to a GitHub repo&lt;/li&gt;
&lt;li&gt;Build and run a FastAPI hello-world app, explore &lt;code&gt;/docs&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Set up a &lt;code&gt;.env&lt;/code&gt; file for secrets and confirm it's gitignored&lt;/li&gt;
&lt;li&gt;Start this build log&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Step 1: Project Foundations
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Create the folder
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;my-project-1
&lt;span class="nb"&gt;cd &lt;/span&gt;my-project-1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Initialize git &lt;em&gt;first&lt;/em&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why first?&lt;/strong&gt; So every file created from this point on is tracked from day one — no risk of forgetting to init later.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create &lt;code&gt;.gitignore&lt;/code&gt; &lt;em&gt;before&lt;/em&gt; installing anything
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; .gitignore &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
venv/
__pycache__/
.env
.DS_Store
&lt;/span&gt;&lt;span class="no"&gt;EOF
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why before the virtual environment?&lt;/strong&gt; If you create the venv first, git could briefly see hundreds of library files before you've excluded them. Doing this first avoids ever accidentally staging things you don't want tracked.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How this command works:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;cat&lt;/code&gt; — normally reads and displays file content, but here it's not reading a file — it's about to receive typed input instead.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;gt;&lt;/code&gt; — redirect operator. Instead of printing to the screen, the output is written into a file. Since &lt;code&gt;.gitignore&lt;/code&gt; doesn't exist yet, this creates it.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;&amp;lt; 'EOF'&lt;/code&gt; — a &lt;strong&gt;heredoc&lt;/strong&gt;. It tells bash: "don't wait for a real file — treat everything typed next, up until a line that says exactly &lt;code&gt;EOF&lt;/code&gt;, as the input text."&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;EOF&lt;/code&gt; (closing) — signals "stop, that's the end of the input."&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; &lt;code&gt;EOF&lt;/code&gt; isn't a special keyword — it's just a convention. You could use &lt;code&gt;BANANA&lt;/code&gt; instead, and it would work identically: bash treats everything as raw text until it sees a &lt;em&gt;line&lt;/em&gt; containing exactly that word. &lt;code&gt;EOF&lt;/code&gt; ("End Of File") is used everywhere because it instantly signals intent to anyone reading the script.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This heredoc syntax is bash-specific. PowerShell uses a different syntax (&lt;code&gt;@" ... "@ | Out-File&lt;/code&gt;) — match the syntax to the shell you're actually in.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Create and activate the virtual environment
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python &lt;span class="nt"&gt;-m&lt;/span&gt; venv venv
&lt;span class="nb"&gt;source &lt;/span&gt;venv/Scripts/activate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What this does:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;python -m venv venv&lt;/code&gt; — runs Python's built-in &lt;code&gt;venv&lt;/code&gt; module, creating a folder (&lt;code&gt;venv/&lt;/code&gt;) containing an isolated copy of Python and its own package directory.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;source venv/Scripts/activate&lt;/code&gt; — activates it, redirecting your terminal's &lt;code&gt;python&lt;/code&gt;/&lt;code&gt;pip&lt;/code&gt; to point inside &lt;code&gt;venv/&lt;/code&gt; instead of your system-wide install. You'll know it worked when &lt;code&gt;(venv)&lt;/code&gt; appears in your prompt.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The folder is named &lt;code&gt;Scripts/&lt;/code&gt; on Windows and &lt;code&gt;bin/&lt;/code&gt; on Linux/macOS. If &lt;code&gt;source venv/bin/activate&lt;/code&gt; fails with "No such file or directory," check which one actually exists with &lt;code&gt;ls venv&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Install packages + freeze requirements
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;requests
pip freeze &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why this matters:&lt;/strong&gt; every time you install something new, freeze it into &lt;code&gt;requirements.txt&lt;/code&gt;. This makes the exact dependency set shareable — anyone (including future-you) can recreate your environment with &lt;code&gt;pip install -r requirements.txt&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  First commit
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;touch &lt;/span&gt;README.md main.py      &lt;span class="c"&gt;# or: New-Item README.md, main.py   (PowerShell)&lt;/span&gt;
git add &lt;span class="nb"&gt;.&lt;/span&gt;
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Initial project setup"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What makes a good commit message:&lt;/strong&gt; it describes &lt;em&gt;what changed and why&lt;/em&gt; — not just "update" or "fix stuff."&lt;/p&gt;

&lt;h3&gt;
  
  
  Connect to GitHub
&lt;/h3&gt;

&lt;p&gt;Create a new, empty repository on GitHub first, then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git remote add origin &amp;lt;your-repo-url&amp;gt;
git branch &lt;span class="nt"&gt;-M&lt;/span&gt; main
git push &lt;span class="nt"&gt;-u&lt;/span&gt; origin main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Breaking this down:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git remote add origin &amp;lt;url&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Registers a remote connection, nicknamed &lt;code&gt;origin&lt;/code&gt; (convention), pointing at your GitHub repo's URL. No data moves yet — this just registers the address.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git branch -M main&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Renames your current branch to &lt;code&gt;main&lt;/code&gt; (forcing it even if a branch with that name exists), matching what GitHub expects by default.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git push -u origin main&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Uploads your commits to GitHub for the first time. &lt;code&gt;-u&lt;/code&gt; sets up tracking between local &lt;code&gt;main&lt;/code&gt; and &lt;code&gt;origin/main&lt;/code&gt;, so every push after this can just be &lt;code&gt;git push&lt;/code&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Run this sequence once per project&lt;/strong&gt; — right at the start, connecting a fresh local repo to a fresh GitHub repo.&lt;/p&gt;

&lt;h3&gt;
  
  
  The repeatable loop (used for every session after this)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;source &lt;/span&gt;venv/Scripts/activate
&lt;span class="c"&gt;# ... work, install packages ...&lt;/span&gt;
pip freeze &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; requirements.txt
git add &lt;span class="nb"&gt;.&lt;/span&gt;
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"clear description of change"&lt;/span&gt;
git push
deactivate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The commit flow, in isolation
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git status                          &lt;span class="c"&gt;# check what changed&lt;/span&gt;
git add .gitignore                  &lt;span class="c"&gt;# stage the change&lt;/span&gt;
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"clear description"&lt;/span&gt;   &lt;span class="c"&gt;# commit with a real message&lt;/span&gt;
git push                            &lt;span class="c"&gt;# push to GitHub&lt;/span&gt;
git log &lt;span class="nt"&gt;--oneline&lt;/span&gt; &lt;span class="nt"&gt;-1&lt;/span&gt;                &lt;span class="c"&gt;# sanity check&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 2: Getting FastAPI Running Locally
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Ensure the virtual environment is active
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;source &lt;/span&gt;venv/Scripts/activate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Install FastAPI and Uvicorn
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;fastapi uvicorn
pip freeze &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;FastAPI&lt;/strong&gt; — lets you define API routes/endpoints in Python. It doesn't serve requests on its own — it needs an &lt;strong&gt;ASGI&lt;/strong&gt; (Asynchronous Server Gateway Interface) server to actually run.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Uvicorn&lt;/strong&gt; — a lightweight ASGI server that runs your app and listens for HTTP requests.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Create the app file
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;code &lt;span class="nb"&gt;.&lt;/span&gt;   &lt;span class="c"&gt;# opens the current folder in VS Code&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Structure of &lt;code&gt;main.py&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Import &lt;code&gt;FastAPI&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Create an &lt;strong&gt;application instance&lt;/strong&gt; (&lt;code&gt;app = FastAPI()&lt;/code&gt;) for Uvicorn to run&lt;/li&gt;
&lt;li&gt;Use a &lt;strong&gt;decorator&lt;/strong&gt; (&lt;code&gt;@app.get("/")&lt;/code&gt;) so that a GET request to the root URL runs the function below it&lt;/li&gt;
&lt;li&gt;Define the function to handle the request&lt;/li&gt;
&lt;li&gt;Return the response (FastAPI auto-converts a Python dict to JSON)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;fastapi&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;FastAPI&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;FastAPI&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="nd"&gt;@app.get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;read_root&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;message&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Hello, World!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Start the server
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;uvicorn main:app &lt;span class="nt"&gt;--reload&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;main:app&lt;/code&gt; — tells Uvicorn to look inside &lt;code&gt;main.py&lt;/code&gt; for an object named &lt;code&gt;app&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--reload&lt;/code&gt; — automatically restarts the server whenever you save a code change.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Visit &lt;code&gt;http://127.0.0.1:8000&lt;/code&gt; to see the JSON response.&lt;/p&gt;

&lt;h3&gt;
  
  
  Check the automatic docs
&lt;/h3&gt;

&lt;p&gt;Visit &lt;code&gt;http://127.0.0.1:8000/docs&lt;/code&gt; — FastAPI auto-generates a full interactive API explorer (Swagger UI / OpenAPI spec), built entirely from your route definitions. No docs code required.&lt;/p&gt;

&lt;p&gt;A read-only alternative view is available at &lt;code&gt;/redoc&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 3: Secrets — the &lt;code&gt;.env&lt;/code&gt; File
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Create &lt;code&gt;.env&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; .env &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
APP_SECRET=super-secret-value-123
&lt;/span&gt;&lt;span class="no"&gt;EOF
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Confirm it's actually ignored — don't just assume
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git status                 &lt;span class="c"&gt;# .env should not appear anywhere in the output&lt;/span&gt;
git check-ignore &lt;span class="nt"&gt;-v&lt;/span&gt; .env   &lt;span class="c"&gt;# the definitive test&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;git check-ignore -v&lt;/code&gt; reports exactly which line in which file is causing the file to be ignored, e.g.:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;.&lt;span class="n"&gt;gitignore&lt;/span&gt;:&lt;span class="m"&gt;7&lt;/span&gt;:.&lt;span class="n"&gt;env&lt;/span&gt;    .&lt;span class="n"&gt;env&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; &lt;code&gt;.gitignore&lt;/code&gt; only prevents git from tracking files it &lt;em&gt;hasn't already started tracking&lt;/em&gt;. If a secret was committed before being added to &lt;code&gt;.gitignore&lt;/code&gt;, it will still exist in your git history. Setting up the ignore rule &lt;strong&gt;before&lt;/strong&gt; the first &lt;code&gt;git add&lt;/code&gt; — which is what happened here — avoids this entirely.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Step 4: Start This Build Log
&lt;/h2&gt;

&lt;p&gt;Keep two documents, for two different audiences:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;BUILD_LOG.md&lt;/code&gt;&lt;/strong&gt; (this file) — chronological, for future-me. What I did, what broke, what I learned. Terse is fine.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;README.md&lt;/code&gt;&lt;/strong&gt; — for other people (or future-me pretending to be someone else). What the project is and how to run it — a snapshot of current state, not a diary.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The most useful log entries capture the &lt;em&gt;why&lt;/em&gt;, not just the &lt;em&gt;what&lt;/em&gt; — especially for snags:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;## 2026-07-16&lt;/span&gt;
&lt;span class="p"&gt;
-&lt;/span&gt; Set up project folder, git repo, and Python virtual environment
&lt;span class="p"&gt;-&lt;/span&gt; Installed FastAPI + Uvicorn, built a hello-world app with a single GET / route
&lt;span class="p"&gt;-&lt;/span&gt; Confirmed it runs locally and explored the auto-generated /docs (Swagger UI)
&lt;span class="p"&gt;-&lt;/span&gt; Set up a .env file for secrets and confirmed it's properly gitignored
  (learned: .gitignore only blocks files git hasn't tracked yet — order matters)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Commit it the same way as everything else:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add BUILD_LOG.md
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Start build log with first entry"&lt;/span&gt;
git push
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Key Habits to Keep
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Commit small, commit often, write real messages&lt;/strong&gt; — a message should answer "what changed and why," not just "update."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;.gitignore&lt;/code&gt; before &lt;code&gt;git add&lt;/code&gt;&lt;/strong&gt;, always — order of operations is what actually protects secrets.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Freeze requirements on every install&lt;/strong&gt;, not just at the end.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Log the "why" and the snags&lt;/strong&gt;, not just the "what" — that's the part future-you will actually forget.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>beginners</category>
      <category>git</category>
      <category>python</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
