DEV Community

Cover image for Why My Game Worked on Itch.io but Died on GitHub Clone (The .gitignore Trap) 🤡
Weird Codes
Weird Codes

Posted on

Why My Game Worked on Itch.io but Died on GitHub Clone (The .gitignore Trap) 🤡

Hey DEV Community! 👋
I am currently building MOKSHA, an HTML5 Canvas game deeply rooted in Vedic philosophy. The game involves managing your Karma, avoiding Maya (Illusions), and achieving spiritual liberation.
Ironically, while building a game about waking up from cosmic illusions, I fell into a technical illusion myself yesterday. Let me tell you a chaotic detective story about how my game froze on a fresh repository clone, and how I found the silent assassin hiding in plain sight. 🤡


🚫 The Disaster: Works on Itch.io, Freezes on GitHub

So, there I was, ready to release a fresh update. I generated my build packages locally, zipped them up, and proudly uploaded them to Itch.io. I hit Publish, tested the live link, and everything worked flawlessly. High scores, smooth frames, total spiritual awakening.
Then, I casually walked over to my terminal, ran git add . followed by git push, and went to bed thinking I was an absolute pro.
The next morning, I wanted to double-check my clean repository, so I cloned it fresh into a new folder. I booted up the local server, and... the entire game was completely unclickable. Dead clicks. Frozen canvas. Total illusion (Maya). 💀
Opening up the browser console revealed a fierce wall of red text:

style.min.css:1 Failed to load resource: the server responded with a status of 404 (Not Found)
main.min.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)


🕵️‍♂️ The Realization: It Wasn't Me, It Was My .gitignore!

Initially, I blamed my sleep-deprived brain, thinking I forgot the chronological order of pushing and building. But when I opened my root directory to inspect the crime scene, I found the real culprit staring right back at me on lines 46 and 50 of my .gitignore file:

dist/
*.zip
index.min.html

The Ultimate Trap Exposed 🪤

Because dist/ was explicitly blacklisted in my .gitignore, Git was literally doing its job perfectly by completely ignoring my production builds during staging!
Here is exactly how the loop went down:

  1. I would run my build command locally.
  2. The dist/ folder would generate perfectly on my local computer.
  3. I manually zipped it and uploaded it to Itch.io (which is why Itch.io worked flawlessly!).
  4. I ran git push, blindly believing everything went to GitHub.

But Git silently left the dist/ folder behind on my machine. When I cloned the repository fresh, the HTML base file was aggressively looking for dist/main.min.js. Since it didn't exist in the repo, the main game script never loaded. No script = No event listeners = A completely unclickable canvas!


🛠️ The Cosmic Realignment (The Fix)

Instead of overcomplicating things by fighting with hidden distribution folder pipelines for a lightweight web game, I decided to keep the repository structure completely transparent. I bypassed the production dist/ path entirely and routed the asset links straight to my raw source files:

  • Updated dist/style.min.css ➡️ style.css
  • Updated dist/main.min.js ➡️ src/main.js

After updating the HTML paths, committing, and pushing to GitHub, the miracle happened. The fresh clone initialized instantly, the event listeners attached perfectly, and the game was beautifully clickable again!


🧘‍♂️ Lessons Learned From the Samsara of Coding

  1. Inspect your .gitignore early: It doesn't care about your deployment feelings. If a folder is blacklisted, it stays local forever.
  2. A 404 can freeze your entire UI: If your canvas element acts like a dead image, check if your script files actually made it past the repository gates.

Now that the asset pipes are clear and tracked correctly on GitHub, I am taking this clean codebase straight into Google AI Studio to implement the new Vedic Tutorial Mode and a bilingual English/Hindi toggle button.
Drop a comment below if your .gitignore has ever gaslit you into believing your code was broken. Let's share the trauma! 😂


🤖 AI Assistant Disclaimer: This highly dramatic devlog was structured and polished with the help of an AI collaborator to turn a frustrating debugging session into an educational sushupti (deep awareness) moment for other indie devs.


Top comments (0)