DEV Community

Cover image for Understanding Git in a Simple Way - Part 4
Ganesh Kumar
Ganesh Kumar

Posted on

Understanding Git in a Simple Way - Part 4

Hello, I'm Ganesh. I'm working on FreeDevTools online, currently building a single platform for all development tools, cheat codes, and TL; DRs — a free, open-source hub where developers can quickly find and use tools without the hassle of searching the internet.

In this blog, we will learn about git checkout, git reset, and git revert.

These 3 commands all do undo things, but they do different operations, and they are confusing.

Git Checkout

This command will move only the head.

Git head is now pointing to c3.

Now, when we check out to c1

git checkout c1
Enter fullscreen mode Exit fullscreen mode

Now, the head is detached, and it is pointing to c1.

Note: No commits are changed, no history is changed, and no branch is moved.

This means we are just seeing changes made in a particular commit.

Git reset

Git reset is similar to git checkout

Here we have 4 commits

When we use git reset c1

Head moves, and remaining commits will be orphaned.

  1. --soft
    Moves branch only, keep staging and working direcotry.

  2. --mixed
    Moves branch, clears staging, keeps working directory.

  3. --hard
    Moves the branch, clears the staging and working directory.

Conclution

We understood that checkout used to see commit changes and reset to remove commits.

In the next blog, we will learn about git revert.


FreeDevTools

I’ve been building for FreeDevTools.

A collection of UI/UX-focused tools crafted to simplify workflows, save time, and reduce friction when searching for tools and materials.

Any feedback or contributions are welcome!

It’s online, open-source, and ready for anyone to use.

👉 Check it out: FreeDevTools

⭐ Star it on GitHub: freedevtools

Top comments (0)