DEV Community

Cover image for Week 7 - You're not stuck, you just skipped the basics: Git beyond push
Adam Neves
Adam Neves

Posted on

Week 7 - You're not stuck, you just skipped the basics: Git beyond push

Before we dive in, I want to apologize for the delay in continuing this series.

I’ve been overloaded with work and handling a lot of demands lately, which has left me with little time to write.

Thanks for your patience, let’s pick up where we left off.


Many people think they know Git because they learned git add, git commit, and git push.

The truth is, that's just the tip of the iceberg.

If you want to stop struggling and start using Git effectively, you need to understand what happens beyond the push.


Branches: much more than “a copy of the code”

A branch is just a pointer to a commit, but it gives you the freedom to work in parallel without messing up main.

Want to create a new feature?

git checkout -b my-feature
Enter fullscreen mode Exit fullscreen mode

Keep branches short and focused, and don’t be afraid to create as many as needed.


Merge and Rebase: same road, different routes

  • Merge: joins paths and preserves history.
  git checkout main
  git merge my-feature
Enter fullscreen mode Exit fullscreen mode
  • Rebase: rewrites history as if your work always started from the latest version.
  git checkout my-feature
  git rebase main
Enter fullscreen mode Exit fullscreen mode

Rebase keeps history cleaner but requires caution in shared branches.


Stash: Git’s secret pocket

Started something and need to switch branches without losing work?

stash saves your changes without committing.

git stash
git checkout another-branch
git stash pop
Enter fullscreen mode Exit fullscreen mode

Reflog: the time machine

If you “lost” a commit or reset something by mistake, reflog can save you.

It records everything your HEAD has pointed to.

git reflog
git checkout <hash>
Enter fullscreen mode Exit fullscreen mode

Flow strategies: choose your map

  • GitHub Flow: simple, great for continuous deployment.
  • Trunk Based: focuses on integrating quickly, avoiding long-lived branches.
  • Git Flow: more formal, good for projects with defined release cycles.

The choice depends on the team, delivery pace, and coordination level.


Broken history: now what?

If a problematic commit made it into main, you can:

  • Revert: creates a new commit undoing changes (git revert).
  • Reset: deletes commits (dangerous if already pushed).
  • Cherry-pick: reuse only what’s useful from a lost commit.

In summary

Git is not just about storing code, it’s about telling your project’s story clearly and safely.

Mastering branches, merges, rebases, and tools like stash and reflog will make you much more confident in experimenting and fixing mistakes.

Next time you type git push, remember: that’s just the beginning.

Top comments (0)