DEV Community

Cover image for 20 Git Commands you (probably) didn't know about
Rocky
Rocky

Posted on

20 Git Commands you (probably) didn't know about

If you've ever browsed the git manual (or run man git), then you'll have noticed there's a whole lot more to git than what most of us use on a daily basis. A lot of these commands are incredibly powerful and can make your life a lot easier (others are a bit niche, but still good to know).

This post outlines 20 of my favourite under-used git features, which you can use to level up your development process, impress your colleagues, help you answer git interview questions, and most importantly - have fun with!

Discover: Super Useful CSS Resources

Here are 20 Git commands that you may not be familiar with:

  1. git stash - This command allows you to temporarily save changes that are not ready to be committed, and switch to a different branch. You can later reapply the changes with git stash apply.
  2. git stash list - This command lists all of the stashes that you have saved with git stash.
  3. git stash show - This command shows the changes that are contained in a specific stash.
  4. git stash drop - This command removes a specific stash from the stash list.
  5. git stash clear - This command removes all stashes from the stash list.
  6. git cherry-pick - This command allows you to apply a specific commit from one branch to another.

Discover: 20 JavaScript Concepts Every Developer Should Know

  1. git rebase - This command allows you to reapply commits on top of another base tip.
  2. git bisect - This command helps you find the commit that introduced a bug by performing a binary search through the commit history.
  3. git blame - This command shows you the last person to modify each line in a file, along with the commit that made the change.
  4. git grep - This command allows you to search for a pattern within your repository.
  5. git shortlog - This command shows a summary of commits grouped by author.
  6. git describe - This command shows a human-readable description of a commit, based on the closest tag.
  7. git show-branch - This command shows a summary of branches and their commits.
  8. git log --graph - This command shows a visual representation of your commit history, with branches and merges.
  9. git clean - This command removes untracked files from your repository.
  10. git submodule - This command allows you to include other Git repositories within your repository as subdirectories.
  11. git stash branch - This command creates a new branch from your stash, and removes the stash.
  12. git cherry - This command shows a list of commits that are in one branch, but not in another.
  13. git ls-files - This command lists all of the files in your repository.
  14. git merge --squash - This command merges multiple commits into a single commit, without creating a merge commit.

Follow Us On : Instagram.... Twitter .... Facebook.... Telegram .... Website

I hope these Git commands are useful to you! Let me know if you have any questions.

Discover: Why do Programmer Care About Set Theory

Top comments (0)