DEV Community

Cover image for Git Essentials: The commands you'll actually use as a Developer
Shagun Mistry
Shagun Mistry

Posted on

4

Git Essentials: The commands you'll actually use as a Developer

I've worked as a Software Developer and Engineer for past 9 years.
Based on my career at over 10 different companies, I've created a list of git commands that are of use in most of the normal day-to-day development:

  • git status: Your trusty guide. Tells you what files have been changed, added, or are untracked. Use it frequently to stay on top of your project's state.
  • git add .: Stages all changes in your current directory, preparing them to be included in the next commit. Remember the dot!
  • git commit -m "your message here": Saves your changes with a descriptive message. Good commit messages are like breadcrumbs for future you!
  • git checkout <branch_name>: Switches to a different branch. Think of branches like parallel universes for your code.
  • git checkout -: A quick way to jump back to the branch you were on previously. Like a handy "undo" button for branches.
  • git merge <branch_name>: Combines changes from another branch into your current one.
  • git pull: Fetches the latest changes from a remote repository and merges them into your current branch. Stay in sync with your team.
  • git reset --hard: Caution! Discards all uncommitted changes in your working directory. Use with care when you need a clean slate.
  • git stash: Temporarily saves your changes without committing them. Useful when you need to switch branches but aren't ready to commit yet.
  • git stash pop: Reapplies your stashed changes. Bring back those changes when you're ready to work on them again.
  • git cherry-pick -m 1 <commit_hash>: Applies a specific commit from another branch to your current branch. The -m 1 is crucial when the commit is part of a merge, ensuring you pick the correct change. Use this sparingly to avoid messy history.

Bonus Tip:

  • Use git log to view the commit history. It's like a time machine for your code!

Master these, and you'll be well on your way to Git mastery!

If you liked this bite-sized tutorial, please share and subscribe!

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

Top comments (0)

Cloudinary image

Optimize, customize, deliver, manage and analyze your images.

Remove background in all your web images at the same time, use outpainting to expand images with matching content, remove objects via open-set object detection and fill, recolor, crop, resize... Discover these and hundreds more ways to manage your web images and videos on a scale.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay