DEV Community

Arup Bhowmik Pritom
Arup Bhowmik Pritom

Posted on

From Zero to Live Production: A Beginner's Guide to Git, GitHub, Local Development & Auto-Deployment

Project: 2D3D Lab (Galahad43/2d3dlab)

Audience: Complete beginners who just downloaded VS Code and want to understand how real-world project management, Git, GitHub, local testing, bug fixing, and live deployment work together.

Style: Story-driven developer blog with simple real-world analogies.


👋 Introduction: Where Our Journey Starts

Imagine you just installed VS Code on your laptop five minutes ago. Someone invited you as a contributor to a real, live production website on GitHub: https://github.com/Galahad43/2d3dlab.

Your goal is simple:

  1. Bring the project code from GitHub onto your computer.
  2. Run and test the website locally without breaking the live site.
  3. Build a new feature (a Google Sites / Wix–style live visual website editor) and fix bugs.
  4. Send your finished code back to GitHub so it automatically deploys to the live domain (https://www.2d3dlab.com).

Let's walk through every single step of how this works in plain English!


🧠 Chapter 1: VS Code, Git, and GitHub — Who Does What?

Many beginners confuse Git and GitHub. Let's clear that up forever with a "Book Writing & Publishing" analogy:

Tool What It Actually Is Real-World Analogy
VS Code Your code editor Your notebook and pen on your desk where you write and edit chapters.
Git Version-control software running locally on your PC A time-machine camera sitting next to your notebook. Whenever you finish a paragraph, it takes a permanent snapshot so you can always rewind if you make a mistake.
GitHub A cloud platform on the internet for hosting Git projects The central publishing house / cloud vault where the master copy lives and multiple contributors collaborate safely.

🔑 Chapter 2: Bringing the Project Home (git clone) & The Two-Key Mystery

❌ Mistake #1: Pasting a URL Directly into the Terminal

At the start, we tried pasting the repository URL directly into Git Bash:

$ https://github.com/Galahad43/2d3dlab
bash: https://github.com/Galahad43/2d3dlab: No such file or directory
Enter fullscreen mode Exit fullscreen mode

Why did that happen?

A terminal is like a literal robot. If you just hand it a web address, it assumes you're trying to launch a program on your hard drive with that name. You have to give it the exact command: "Use Git to clone (copy) this repository here":

git clone <REPO_URL> .
Enter fullscreen mode Exit fullscreen mode

(Notice the dot . at the end—that tells Git: "Put the files directly inside the folder I'm already in instead of creating a new subfolder.")


🔐 Mystery #2: "I Accepted the Invite—Why Does Git Say Repository not found?!"

This was one of the coolest troubleshooting moments of the whole project.

Galahad43/2d3dlab is a Private Repository (think of it as a locked room). The owner invited your GitHub account CodeWithPritom (pritombhowmik360@gmail.com), and you accepted the invite in your browser—so you could see the repo on GitHub.com. Yet when Git tried to download it from the terminal, GitHub replied:

ERROR: Repository not found.
Enter fullscreen mode Exit fullscreen mode

Why? Think of house keys:

  • Your Windows PC had two GitHub SSH keys stored inside ~/.ssh/:
    1. One key belonging to Pritom-360 (~/.ssh/id_ed25519).
    2. Another key belonging to CodeWithPritom (~/.ssh/id_ed25519_codewithpritom).
  • When we used the default address git@github.com, Git automatically pulled out the Pritom-360 key and knocked on the door of Galahad43/2d3dlab.
  • Since Pritom-360 was not on the guest list (only CodeWithPritom was!), GitHub hid the room completely for security and said Repository not found.

The Fix:

Your ~/.ssh/config file already defined a custom host alias github-codewithpritom linked to CodeWithPritom's key. Once we pointed Git to that alias, the door unlocked instantly:

# Standard clone into an empty folder:
git clone git@github-codewithpritom:Galahad43/2d3dlab.git .

# Or, when a file (like doc.md) already exists in the folder:
git init
git remote add origin git@github-codewithpritom:Galahad43/2d3dlab.git
git fetch origin
git checkout -b main origin/main
Enter fullscreen mode Exit fullscreen mode

🍳 Chapter 3: Testing in Your Own Kitchen (localhost & Local MySQL)

Analogy: Before serving a new dish to 1,000 wedding guests, a chef always cooks and tastes a test batch in their own kitchen first!

In software engineering, you never edit a live production website blindly. You run a safe copy on your own computer (localhost).

  1. Starting a Local Web Server: With PHP 8.2 installed on your machine, one command turns your project folder into a working local web server:
   php -S localhost:8000
Enter fullscreen mode Exit fullscreen mode

Open http://localhost:8000 in your browser, and the website runs right on your PC.

  1. Local Database vs. Live ProCloudify Database:
    • The live site runs on ProCloudify hosting. For security, hosting providers firewall MySQL port 3306 so external computers cannot connect directly over the public internet.
    • So we created a matching local database named ddlabcom_wp909 inside your local XAMPP MySQL server.
    • Smart Environment Switch (db.php): We updated db.php to inspect the host name:
      • When accessed on the live domain (2d3dlab.com), it connects straight to the live ProCloudify cPanel database credentials.
      • When accessed on localhost or 127.0.0.1, it uses your local XAMPP MySQL credentials (root).
      • That means zero risk of breaking production credentials when deploying!
    • Want real live data on your local PC? Go to ProCloudify cPanel → phpMyAdmin → select ddlabcom_wp909 → Export (downloads .sql) → open local phpMyAdmin (http://127.0.0.1/phpmyadmin/) → select ddlabcom_wp909 → Import.

🎨 Chapter 4: Real-World Engineering — UX Fixes & Building the Visual Editor

Once the project was running locally, we audited every page and fixed major UI/UX and logic issues before building the live editor:

1. Why Buttons Only Worked at the Very Corner (includes/header.php)

  • The Bug: The top navigation bar (header.site-header) had position: fixed; top: 0; background-color: transparent;. Even though it looked invisible before scrolling, its transparent box sat on top of the first ~90px of every page—swallowing mouse clicks on the Hero Slider and builder buttons unless your cursor hit the exact edge! Plus, .content-container was used across pages without ever being defined in CSS, and hardcoded margin-left: 5rem; rules in portfolio.php broke mobile layouts.
  • The Fix: We changed the navbar to a clean, classic solid white sticky header (position: sticky; top: var(--builder-offset, 0px);, with overflow-x: clip on html, body so sticky behavior stays intact), defined .content-container globally, and made all page grids responsive across mobile, tablet, and desktop.

2. Google Sites / Wix–Style Real-Time Visual Builder

  • Built across includes/visual_builder.php, admin_api.php, and includes/cms_helpers.php.
  • No Flickering Hover Bars: Instead of buttons appearing only on hover (which disappeared as soon as the mouse moved or the carousel auto-slid every 5 seconds), admin mode pauses carousel auto-advance and docks a permanent control header (.cms-block-header) onto every editable slide, card, and section (✏️ Edit, 🖼️ Image, ⬆, ⬇, 🗑️).
  • Drag-and-Drop + Components Library: Admins can open + Components Library to insert new Hero Slides, Feature Cards, Portfolio Cards, Content Sections (text + image), and CTA Banners in real time, drag cards (⠿) to reorder them, upload images directly, and click any highlighted headline or footer text to edit and persist it in site_settings (cms_text()).
  • Strict Security: Normal visitors and regular customers receive zero builder HTML, CSS, or JavaScript, and admin_api.php rejects any non-admin request.

3. Core Store & Customer Flow Fixes

  • Customer Sign-Up & Sign-In (register.php, login.php): Added password confirmation, minimum 6-character validation, default 'user' role assignment, and safe ?redirect=... preservation (safe_redirect_target()) so customers logging in during checkout go straight back to checkout.
  • Shop Filtering & Service Booking (services-2d.php, services-3d.php, shop.php): Fixed broken ?category=2d / ?category=3d links to use ?dimension=2D / ?dimension=3D (plus category alias support in shop.php), ensured service_requests table creation, auto-filled logged-in customer details, and removed stray zzz text at the bottom of shop.php.
  • Checkout & Orders (checkout.php, order_process.php, dashboard.php, order-details.php, admin.php): Saved order price (total_amount), currency, and customer info dynamically based on table columns, fixed $_SESSION['email'] → $_SESSION['user_email'] in order_process.php, and replaced broken assets/placeholder.jpg fallbacks with assets/banner.jpg.

📦 Chapter 5: The Gatekeeper (.gitignore), Packing the Box (Commit) & Shipping (Push)

After testing every route and flow locally, it was time to ship our changes to GitHub. Think of this like sending a courier parcel:

1. The Gatekeeper List: .gitignore

Before packing a shipping box from your desk, you make sure your coffee mug and scratch paper stay off the parcel list.

.gitignore acts as that gatekeeper:

includes/currency_rates_cache.json
uploads/
*.log
*.tmp
Enter fullscreen mode Exit fullscreen mode

This ensures local cache files, test cookies, and your local uploads/ folder are never pushed to GitHub and never overwrite live uploaded product images on the server.

2. The 4 Commands to Ship Code

  1. git status → Look at your desk to see which files are modified or untracked.
  2. git add -A → Place all intended files inside the shipping box (Staging Area).
  3. git commit -m "Add Realtime Visual Builder..." → Tape the box shut and write a clear label on it (creating checkpoint commit *73a8f0c*).
  4. git push origin main → Hand the sealed box to the courier to deliver it to the *main** branch on GitHub (origin)!*

🤖 Chapter 6: The Automated Delivery Robot (GitHub Actions CI/CD)

Minutes after running git push origin main, the live site at https://www.2d3dlab.com automatically updated—without anyone opening cPanel or dragging files manually!

How? Because of .github/workflows/deploy.yml:

  • Analogy: Think of GitHub Actions as a 24/7 robotic delivery van parked inside GitHub's warehouse.
  • Every time a new commit arrives on the main branch, the robot wakes up, reads the encrypted FTP_SERVER, FTP_USERNAME, and FTP_PASSWORD stored safely in GitHub Secrets, and runs SamKirkland/FTP-Deploy-Action@v4.3.5 to sync the updated code directly into ProCloudify's ./public_html/ folder—keeping the live database and existing uploads untouched.

🧰 Chapter 7: Daily Developer Cheatsheet & Team Best Practices

🔄 Your Everyday 4-Step Loop

Whenever you open VS Code to make a change in the future, follow this simple loop:

# 1. Pull any updates teammates pushed while you were away
git pull origin main

# 2. Edit in VS Code & test locally (php -S localhost:8000), then inspect changes
git status

# 3. Pack and label your snapshot
git add -A
git commit -m "Describe clearly what you changed"

# 4. Ship to GitHub (triggers automatic live deployment!)
git push origin main
Enter fullscreen mode Exit fullscreen mode

🌿 Working on Bigger Features Safely (Branching & Pull Requests)

When working on a multi-day feature in a team, never leave half-finished code on main. Create a side lane (Branch):

git checkout -b feature/new-gallery    # Create & switch to a safe side lane
# ... edit and commit on your branch ...
git push -u origin feature/new-gallery # Push the branch to GitHub
Enter fullscreen mode Exit fullscreen mode

Then open Compare & pull request on GitHub so teammates can review your changes before merging into main.


🔐 Quick Credentials & Testing Reference

  • Run Local Server: php -S localhost:8000 → visit http://localhost:8000
  • Local Test Admin Account (Local MySQL Only):
    • Login URL: http://localhost:8000/login.php
    • Email: admin@2d3dlab.com
    • Password: admin123
  • Live Production Website (https://www.2d3dlab.com): Your live ProCloudify database (users, products, orders, site_content) was never altered or overwritten. Log in at https://www.2d3dlab.com/login.php using your real live admin email and password to use the Visual Builder on the live site!

Happy Coding! Every experienced developer started right where you are—running their very first git clone and git push. 💻✨

Top comments (0)