DEV Community

10 Git Commands I Wish I Learned Sooner (opens in new tab)

Discussed on DEV

We all learn Git the hard way. You start with add, commit, push — and that works until the day you accidentally commit to main or delete a branch you meant to keep. Here are 10 Git commands I discovered way later than I should have. Each one saved me from a real mess. 1. git switch — The Safe Checkout I used git checkout for everything: switching branches, restoring files, creating new branches. Until one day I ran: git checkout some-file.txt expecting to switch to a branch, and instead wiped...

Read the original article
Sign in to keep reading the full article.

Keyboard Shortcuts

Navigation

Next / previous post
j/k
Open post
oorEnter
Preview post
v

Post Actions

Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Save / unsave
s

Recommendations

Add interest / feed
Enter
Not interested
x

Go to

Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Discover
gb
Search
/

General

Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help