DEV Community

Cover image for Top 10 git commands everyone should know

Top 10 git commands everyone should know

Tom Holloway πŸ• on August 20, 2020

In this article, we're going to go over my top 10 git commands I use almost every day. If you're new to programming, or just getting familiar with ...
Collapse
Β 
juliusdelta profile image
JD Gonzales β€’

These are great!

A couple additional commands that have saved me quite a bit of trouble/work:

git reflog & git cherry-pick.

reflog sort of allows you to view a complete git history of what's happened. It's more extensive than commits cause it includes merges and rebases. So if you have a rebase that goes wrong, you can use reflog to figure out what point in history you need to jump back to and then jump back to that history.

cherry-pick allows you to cherry-pick commits from one branch to another. This is particularly useful if you find yourself putting to much "unrelated" work into a single branch and you need to start a new branch and grab some work you've already done. git cherry-pick <commit-hash>. It'll grab the commit and put it in the branch your working on. It's pretty great.

Collapse
Β 
nyxtom profile image
Tom Holloway πŸ• β€’

So that's what reflog does! Very useful, thanks!

Collapse
Β 
greeder59 profile image
Gordon Reeder β€’

Git push --force. Not to be used trivially. Makes git push act like the old FTP Dump all the Files remote update. Useful for pushing updates to web servers. Becauese someone went around the workflow and fixed a typo directly on the server. Causing the git push command to have a hissy fit when you try to publish an update.

Collapse
Β 
alexandreamadocastro profile image
Alexandre Amado de Castro β€’

Don't get me wrong, git bisect is pretty amazing, but I think that git blame is more on the field of "everyone should know" (in my opinion, obviously)

Collapse
Β 
nyxtom profile image
Tom Holloway πŸ• β€’

Fixed / formatted :)

Collapse
Β 
vlasales profile image
Vlastimil Pospichal β€’

Why :wqa! in Vim? :wq or ZZ is enought.

Collapse
Β 
tilap profile image
Tilap β€’

Nice post!
During interviews, I require developer to know at least a little about git rebase and amend.

It's not a prerequisite to use git.
But it's really important to work in a team.

Collapse
Β 
nyxtom profile image
Tom Holloway πŸ• β€’

Updated!

Collapse
Β 
anrodriguez profile image
An Rodriguez β€’

Nice selection. I would add at least: git checkout -b <new_branch_name>

Collapse
Β 
nyxtom profile image
Tom Holloway πŸ• β€’

Fixed :)

Collapse
Β 
shinesanthosh profile image
Shine Santhosh β€’

Me who only knows git push and git pull... πŸ˜