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 to
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:
- Bring the project code from GitHub onto your computer.
- Run and test the website locally without breaking the live site.
- Build a new feature (a Google Sites / Wixβstyle live visual website editor) and fix bugs.
- 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
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> .
(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 ([email protected]), 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.
Why? Think of house keys:
- Your Windows PC had two GitHub SSH keys stored inside
~/.ssh/:- One key belonging to
Pritom-360(~/.ssh/id_ed25519). - Another key belonging to
CodeWithPritom(~/.ssh/id_ed25519_codewithpritom).
- One key belonging to
- When we used the default address
[email protected], Git automatically pulled out thePritom-360key and knocked on the door ofGalahad43/2d3dlab. - Since
Pritom-360was not on the guest list (onlyCodeWithPritomwas!), GitHub hid the room completely for security and saidRepository 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
π³ 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).
- 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
Open http://localhost:8000 in your browser, and the website runs right on your PC.
-
Local Database vs. Live ProCloudify Database:
- The live site runs on ProCloudify hosting. For security, hosting providers firewall MySQL port
3306so external computers cannot connect directly over the public internet. - So we created a matching local database named
ddlabcom_wp909inside 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
localhostor127.0.0.1, it uses your local XAMPP MySQL credentials (root). - That means zero risk of breaking production credentials when deploying!
- When accessed on the live domain (
-
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/) β selectddlabcom_wp909β Import.
- The live site runs on ProCloudify hosting. For security, hosting providers firewall MySQL port
π¨ 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) hadposition: 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-containerwas used across pages without ever being defined in CSS, and hardcodedmargin-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);, withoverflow-x: cliponhtml, bodyso sticky behavior stays intact), defined.content-containerglobally, 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 Libraryto 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 insite_settings(cms_text()). -
Strict Security: Normal visitors and regular customers receive zero builder HTML, CSS, or JavaScript, and
admin_api.phprejects 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=3dlinks to use?dimension=2D/?dimension=3D(pluscategoryalias support inshop.php), ensuredservice_requeststable creation, auto-filled logged-in customer details, and removed strayzzztext at the bottom ofshop.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']inorder_process.php, and replaced brokenassets/placeholder.jpgfallbacks withassets/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
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
-
git statusβ Look at your desk to see which files are modified or untracked. -
git add -Aβ Place all intended files inside the shipping box (Staging Area). -
git commit -m "Add Realtime Visual Builder..."β Tape the box shut and write a clear label on it (creating checkpoint commit *73a8f0c*). -
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
mainbranch, the robot wakes up, reads the encryptedFTP_SERVER,FTP_USERNAME, andFTP_PASSWORDstored safely in GitHub Secrets, and runsSamKirkland/[email protected]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
πΏ 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
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β visithttp://localhost:8000 -
Local Test Admin Account (Local MySQL Only):
-
Login URL:
http://localhost:8000/login.php -
Email:
[email protected] -
Password:
admin123
-
Login URL:
-
Live Production Website (
https://www.2d3dlab.com): Your live ProCloudify database (users,products,orders,site_content) was never altered or overwritten. Log in athttps://www.2d3dlab.com/login.phpusing 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. π»β¨
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.