DEV Community

Cover image for 🎆THE BEST GIT COMMANDS YOU PROBABLY DON'T KNOW FOR 2024 🎆
Luciano Menezes
Luciano Menezes

Posted on

🎆THE BEST GIT COMMANDS YOU PROBABLY DON'T KNOW FOR 2024 🎆

This post is also available originally in Thread format on Twitter and in English on Dev.To!

⭐- WHAT WILL I SHOW?

In this Thread, I'll show you useful git commands that you probably haven't even heard of and believe me, they are VERY USEFUL

If you're new, I always post content here and on Twitter! Keep an eye out!

✅ 1 - git rebase -i

This GIT command allows you to reorganize, edit, or combine commits during a rebase

This is VERY useful for cleaning up commit history before sending a pull request, merging your changes into a main branch, etc.

See more here!

✅ 2 - git cherry-pick

This command basically allows you to copy a single commit from one branch to another

It's very useful when you need to add a specific change from a commit without merging the entire branch, for example

Ever since I saw it, I've been using it all the time!

See more here!

✅ 3 - git reflog

Reflog records ALL previous HEADs, allowing you to navigate through the change history, even after a rebase or reset

It's incredible for recovering lost commits, reversing accidental actions, among MANY other things

See more here!

✅ 4 - git bisect

This command is used to locate a specific commit that introduced a bug, performing a binary search between two known points

You can use it to quickly identify the cause of problems in large commit histories, for example

See more here!

✅ 5 - git worktree

This one allows you to work with MULTIPLE working directories from the same Git repository

It works great when you need to work on multiple branches simultaneously without switching between directories, etc...

See more here!

✅ 6 - git submodule

Submodules are Git repositories embedded within a main repository

They are useful for including dependencies from other repositories in your project while keeping them as separate entities

With this command, you can manage EVERYTHING from a submodule

See more here!

✅ 7 - git clean

This command is used to remove untracked files from the working directory

It's useful for cleaning up automatically generated files or temporary files that shouldn't be included in the repository (which has happened to me before)

This one's one of the best, I recommend it!

See more here!

✅ 8 - git worktree prune

Prune is used to clean up inactive working directories created by git worktree, which we saw a little while ago

This is useful for freeing up disk space and keeping the workspace always clean!

See more here!

✅ 9 - git sparse-checkout

This feature allows you to work only with a subset of files in a large repository

It's good for saving your time and disk space when cloning or pulling large projects, greatly improving everything

See more here!

✅ 10 - git rerere

This command automatically records successful conflict resolutions and reuses them in similar conflicts in the future

This is AMAZING for saving your time when dealing with recurring conflicts during merge, for example

See more here!

⭐ BONUS - git notes

This command attaches notes to your commits without altering the main timeline

This is GREAT for adding additional information, such as code reviews or review notes, without modifying the original commits

See more here!

😄- THANK YOU

I hope you enjoyed the post!

I always post programming content here and on my Twitter, feel free to follow and give suggestions! I always give credit at the top of the Thread!

Also, check out my other projects!

⭐ better-format: https://github.com/luciano655dev/better-format

⭐ DayKeeper (under development): https://github.com/luciano655dev/daykeeper

Thank you!

Top comments (4)

Collapse
 
jangelodev profile image
João Angelo

Hi Luciano Menezes,
Your tips are very useful
Thanks for sharing

Collapse
 
lilxyzz profile image
Travis

Thank you for sharing, Luciano. Your post helped me learn some new commands 😀

Collapse
 
patzi275 profile image
Patrick Zocli

Thanks, I appreciate. Can you resume it in one image, for sharing ?

Collapse
 
luciano655dev profile image
Luciano Menezes

You can turn my Twitter thread into an image if you want to share!

The only problem is that it's in Brazilian Portuguese, but here's the link!
twitter.com/Luciano655dev/status/1...