🎆THE BEST GIT COMMANDS YOU PROBABLY DON'T KNOW FOR 2024 🎆
Tags: git, commands, new, terminal
Published: 2024-03-18 23:43:03

This post is also available originally in [Thread format on Twitter](https://twitter.com/luciano655dev) and in English on [Dev.To](https://dev.to/luciano655dev)!

![](https://pbs.twimg.com/media/GI-nAE-XEAEfMbQ?format=png&name=small)

# ⭐- 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!](https://git-scm.com/docs/git-rebase)

![](https://pbs.twimg.com/media/GI-rrZAWgAEIueg?format=png&name=small)

# ✅ 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!](https://git-scm.com/docs/git-cherry-pick)

![](https://pbs.twimg.com/media/GI-sVQ2W4AA5z23?format=png&name=small)

# ✅ 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!](https://git-scm.com/docs/git-reflog)

![](https://pbs.twimg.com/media/GI_QaATXcAImYvV?format=png&name=small)

# ✅ 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!](https://git-scm.com/docs/git-bisect)

![](https://pbs.twimg.com/media/GI_QxL-WgAA2wRd?format=png&name=small)

# ✅ 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!](https://git-scm.com/docs/git-worktree)

![](https://pbs.twimg.com/media/GI_RIZtW4AATgWu?format=png&name=small)

# ✅ 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!](https://git-scm.com/docs/git-submodule)

![](https://pbs.twimg.com/media/GI_RghfXAAAxjRv?format=png&name=small)

# ✅ 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!](https://git-scm.com/docs/git-clean)

![](https://pbs.twimg.com/media/GI_SB99XcAAGmK9?format=png&name=small)

# ✅ 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!](https://git-scm.com/docs/git-prune)

![](https://pbs.twimg.com/media/GI_SbnQW4AEK70O?format=png&name=small)

# ✅ 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!](https://git-scm.com/docs/git-sparse-checkout)

![](https://pbs.twimg.com/media/GI_Sh4kXIAAjaP8?format=png&name=small)

# ✅ 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!](https://git-scm.com/docs/git-rerere)

![](https://pbs.twimg.com/media/GI_S4P1WkAELfy_?format=png&name=small)

# ⭐ 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!](https://git-scm.com/docs/git-notes)

![](https://pbs.twimg.com/media/GI_TdzeW0AARHKs?format=png&name=small)

# 😄- THANK YOU

I hope you enjoyed the post!

I always post programming content here and on [my Twitter](https://twitter.com/luciano655dev), 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!**