DEV Community

Cover image for 11 Git Commands I Use Every Day

11 Git Commands I Use Every Day

Domagoj Vidovic on July 15, 2021

When I started my career, I was always afraid of losing my code changes. Sometimes, I would copy the code to text files just to be sure that I won'...
Collapse
 
pyguy9x profile image
pyguy9x •

Hi, I'm newbie and here is my git command

git status : to view exactly what I added
git add .
git commit -m 'Add comment here' .
git status : to view the changed at the end
if everything OK, then
git push : to push all my setting to the server

Collapse
 
mustafa7amdi profile image
mustafa7amdi •

Don't forget "git pull" before "git push" 😉

Collapse
 
husseinmsaqr profile image
Hussein Mohamed • • Edited

Hi Mostafa,
I would tell you, you don't need to do that.
By git push origin/< branch-name > -f
You can push without need use pull before, I hope that helpful for you 👌

Thread Thread
 
mustafa7amdi profile image
mustafa7amdi •

Ya, but be careful this will remove others pushed code

Collapse
 
leealfred profile image
Lee •

These are really helpful and well explained. Thank-you!

Collapse
 
domagojvidovic profile image
Domagoj Vidovic •

Thanks, glad you like it!

Collapse
 
tanth1993 profile image
tanth1993 •

nice bro. on Version 2.2 and later, I use
git switch to switch branch and
git switch -c to create branch instead of using checkout.
I think git checkout is very useful and it can use for multiple purposes, but we can separate the purposes

Collapse
 
darkojoska profile image
Darko •

Very nice cheat sheet Domagoj, thank you for this! For a long time now, I wanted to make my own but you helped me with it :)

The one command that I would add to the list is:
git fetch --all

This is useful when someone just made a new branch onto origin but your vscode did not detect that and you don't see it when you want to change the branch (through ui).

PS. I find some git commands easier to use with ui that vscode provides :)

Collapse
 
maqamylee0 profile image
emmilly immaculate •

Very useful Thank you

Collapse
 
adriano_moreira profile image
Adriano Moreira •

Recently I changed “git checkout” to “git switch” on at branch management

Collapse
 
klukiyan profile image
Kiril Lukiyan •

So glad vscode has all these built into the interface

Collapse
 
frankgracy profile image
Grace Frank •

I never knew i could use revert this is a much cleaner way to do things. I usually do a git rest in my local and tben run push - - force
Thanks for sharing