Back to all articles
Git from zero to deploy: the no-BS guide for modern devs

Git from zero to deploy: the no-BS guide for modern devs

Learn Git the right way, from your first commit to your first deploy, without being a hostage to GUI tools.

Human-architected research synthesized with the assistance of AI personas.
6 min read

TL;DR / Executive Summary

Learn Git the right way, from your first commit to your first deploy, without being a hostage to GUI tools.

💡 TL;DR (Too Long; Didn't Read)

Git is a time machine for your code. In this practical guide you learn: creating your first repository, making purposeful commits, using branches safely, undoing mistakes without panic, and finally preparing everything for your first deploy. No academic theory, no GUI tools, just what actually works.

If you're still afraid of git, it's not because you're "bad". It's because someone probably taught you the wrong way.

In this article you'll learn Git from zero to your first deploy, the way devs actually use it daily — no fluff, no empty theory, and with copy-paste friendly examples.

We'll cover:

  • What Git really is (without academic jargon)
  • Your first commits
  • Branches done right
  • Going back in time without nuking everything
  • Laying the foundations for a sane deploy workflow

1. What Git really is (and why you should care)

Forget the phrase "Git is a distributed version control system".

In practice, Git is:

A time machine for your code, that lets you and your team work together without constantly stepping on each other's toes.

With Git you can:

  • See what changed, when, and by whom
  • Roll back file or project versions
  • Work on multiple features at the same time using branches
  • Test risky ideas without destroying the stable code

People who master Git:

  • Unblock the team when things break
  • Recover "lost" work
  • Avoid deleting each other's changes

It looks like a technical detail, but Git directly affects how senior you look.


2. Getting started: your first repository

Let's create a local repo and make your first commit.

bash
mkdir my-git-project cd my-git-project git init

This creates a .git folder where the magic happens.

Now create a simple file:

bash
echo "console.log('Hello Git!')" > index.js

Check repo status:

bash
git status

You'll see something like:

text
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        index.js

Adding files and making your first commit

  1. Add the file to the staging area:
bash
git add index.js
  1. Register the commit:
bash
git commit -m "feat: first commit of the project"
  1. Check history:
bash
git log --oneline

Congrats, you just created the first point in your time machine.


3. Small commits, big you

If you store everything in a single commit, you're using Git like a glorified USB stick.

Best practices:

  • Small, focused commits
  • Each commit answers: "what was done?" and, when needed, "why?"
  • Skip "fix", "test", "final changes" as messages

Bad example:

bash
git commit -m "final adjustments"

Good example:

bash
git commit -m "fix: correct discount calculation on checkout screen"

Important reminder:

Git is not backup. Git is decision history.


4. Using .gitignore so your team doesn't roast you

Every dev has accidentally committed something they shouldn't: node_modules, .env, massive log files…

Use a .gitignore at the project root to tell Git what to ignore:

gitignore
node_modules/ dist/ .env *.log .idea/ .vscode/

After that, Git will pretend these files don't exist.

Pro tip: generate ready-made .gitignore files for your stack using gitignore.io or GitHub presets.


5. Branches: stop living dangerously on main

If you do everything directly on main, you're not fast — you're reckless.

Healthy workflow:

  • main always stable
  • No crazy experiments directly on main
  • Each feature/bugfix on its own branch

Creating a branch:

bash
git checkout -b feature/login-screen

Going back to main:

bash
git checkout main

Merging your feature into main (simple merge):

bash
git checkout main git pull origin main # update first # after your feature is reviewed and approved git merge feature/login-screen

Branches are cheap. Broken production is expensive.


6. Going back in time without wrecking everything

See what changed before committing

Always review before registering a commit:

bash
git diff # everything that changed git diff --staged # only what you added with git add

This helps avoid:

  • Shipping stray console.log
  • Pushing .env to production
  • Committing temporary files

Reverting a single file

Newer Git:

bash
git restore path/to/file

Older Git:

bash
git checkout HEAD -- path/to/file

This reverts just that file to the last commit.


7. Working with remotes (GitHub, GitLab, etc.)

Let's connect your local repo to a remote (e.g. GitHub):

  1. Create an empty repo on GitHub
  2. Copy the URL (HTTPS or SSH)
  3. In your local project, run:
bash
git remote add origin [email protected]:user/my-git-project.git git branch -M main git push -u origin main

Now your main is synced with the remote.

Whenever you make new changes:

bash
git add . git commit -m "feat: add profile screen" git push

8. Stash: quick pause without making a mess

In the middle of something and someone asks you to fix an urgent bug?

Instead of committing garbage just to "save":

bash
git stash # save your local changes # fix the bug git stash pop # bring your work back

It's like an organized CTRL+Z.


9. Daily Git checklist

If you just do this, you're already above average:

  1. Use git status and git diff before every commit
  2. Have a decent .gitignore from day one
  3. Never work directly on main in serious projects
  4. Use branches per feature/bugfix
  5. Write commit messages that actually mean something
  6. Review before hitting git push

10. Next steps: becoming actually dangerous (in a good way)

To move past the basics and become "the Git person" on your team, study:

  • git rebase (for cleaner history)
  • git revert (to undo without hiding)
  • git reflog (to recover "lost" work)
  • git bisect (to find which commit broke everything)
  • Hooks and aliases (to automate best practices)

In the next articles, we'll go deeper into these topics.

Meanwhile, if this article helped you:

  • Save it to revisit later
  • Share it with that friend who's still scared of Git
  • And keep following the #gittips ;)

Receive new articles

Subscribe to receive notifications about new articles directly to your email

We won't send spam. You can unsubscribe at any time.