7 Git Commands You Probably Don’t Know (But Should)
Shefali

Shefali @devshefali

About: I am a passionate web developer from India. I find pleasure in talking about programming and I love to help everyone who needs any guidance related to programming.

Location:
India
Joined:
Jun 12, 2023

7 Git Commands You Probably Don’t Know (But Should)

Publish Date: Aug 10
15 5

Think you’re good with Git? Most developers use commands like add, commit, and push every day, but Git has many more helpful commands.

In this post, I'll show you 7 Git commands that many experienced developers use to work faster, fix problems, recover lost work, and keep their projects organized.

Before we get started, don’t forget to subscribe to my newsletter!
Get the latest tips, tools, and resources to level up your web development skills delivered straight to your inbox. Subscribe here!

Now, let’s jump right into it!

1. git blame

You can use the git blame command to check who last changed each line of a file and when.

It’s helpful for figuring out who made specific changes or understanding a file’s history.

Learn more!

git blame <filename>
Enter fullscreen mode Exit fullscreen mode

2. git cherry-pick

The git cherry-pick command allows you to copy changes from one commit and apply them to another branch.

It’s helpful when you only want to bring over specific changes without merging the entire branch.

Learn more!

git cherry-pick <commit-hash>
Enter fullscreen mode Exit fullscreen mode

3. git merge — — squash

The git merge — — squash command combines all the changes from one branch into a single commit on another branch.

Instead of creating a merge commit, it squashes all the changes into one, making your commit history cleaner and simpler.

Learn more!

git merge -- squash <branch-to-merge>
Enter fullscreen mode Exit fullscreen mode

4. git rebase -i

The git rebase -i (interactive rebase) command allows you to change your commit history. It lets you reorder, edit, and remove commits.

It gives you more control over your commit log, making it easier to clean up and organize your history.

Learn more!

git rebase -i <base-branch>
Enter fullscreen mode Exit fullscreen mode

5. git reflog

You can use the git reflog command to view a record of all recent changes to your branches and other references.

It can be very useful if you need to recover lost commits or understand recent changes in your project.

Learn more!

git reflog
Enter fullscreen mode Exit fullscreen mode

6. git stash

The git stash command allows you to temporarily save changes that are not yet ready to be committed.

This is handy when you need to switch branches or pull updates but want to save your current work without committing it.

Learn more!

git stash
Enter fullscreen mode Exit fullscreen mode

7. git worktree

The git worktree command allows you to create multiple working directories, each associated with a different branch or commit.

This is useful for working on different tasks simultaneously without having to constantly switch branches.

Learn more!

# Add a new worktree
git worktree add <path> <branch>

# List existing worktrees
git worktree list

# Remove a worktree
git worktree remove <path>

# Remove worktrees that no longer exist
git worktree prune
Enter fullscreen mode Exit fullscreen mode

That’s all for today!

By the way, if you ever need free HTML website templates, I recommend checking out HTMLrev, I use it all the time. And when I’m looking for web design inspiration, Websitevice is one of my go-to resources.

For paid collaboration connect with me at : connect@shefali.dev

If you enjoy my work and want to support what I do:

👉 Become a Patreon supporter
👉 Or buy me a coffee

Every small gesture keeps me going! 💛

Comments 5 total

  • Devluc
    DevlucAug 10, 2025

    Great GitHub tips Shefali. Thanks for sharing them

    • Shefali
      ShefaliAug 11, 2025

      Thanks for your feedback, Lucian!

  • Anik Sikder
    Anik SikderAug 11, 2025

    Love this list. git reflog has saved me from disaster more times than I’d like to admit 😅. One more underused gem: git bisect for hunting down which commit introduced a bug. Curious what’s everyone’s “lifesaver” Git command that’s not in the usual add/commit/push trio?

  • Alex Mahoney
    Alex MahoneyAug 13, 2025

    Nice list for referencing. Thanks!

    • Shefali
      ShefaliAug 13, 2025

      Thank you, Alex!

Add comment