DEV Community

Cover image for My Most Used Git Commands

My Most Used Git Commands

Steffen Pedersen on May 21, 2019

This is not a full guide to which commands you should learn. I just find it inspiring to read about other developers’ habits and work routines. Thi...
Collapse
 
circleofawesome profile image
Samiul Anwar


git checkout -- .

= "oops I fucked up, time to undo all my un-staged changes"

Collapse
 
steffenpedersen profile image
Steffen Pedersen

I will try that one out 😉

Collapse
 
brugnara profile image
Daniele

Hi Steffen.

Thanks for sharing this.

Here's my 50 cents: I use git commit -am "message" when I only have edits to commit.

Collapse
 
steffenpedersen profile image
Steffen Pedersen

This is great!

Collapse
 
anduser96 profile image
Andrei Gatej

Thanks for sharing!

git stash apply stash@{n}

can be replaced with
git stash apply n

Collapse
 
steffenpedersen profile image
Steffen Pedersen

Thank you 🤓

Collapse
 
javaguirre profile image
Javier Aguirre

From now on ‘—force-with-lease’ after rebase, thanks man!

Collapse
 
steffenpedersen profile image
Steffen Pedersen

Use it wisely 😉 It can still be dangerous.

Collapse
 
fernandomaia profile image
Fernando Maia

A great place to learn git fast and in a funny way is Oh shit, git!. It shows what git command should be used in some common situations that we have been/will go through.

Collapse
 
steffenpedersen profile image
Steffen Pedersen

I agree! It's been a while since I read it. Maybe I should try it out again 😃

Collapse
 
ramlev profile image
Hasse R. Hansen

git add --all = git add .

Collapse
 
steffenpedersen profile image
Steffen Pedersen

Du har fuldstændig ret 😃