• Welcome to TalkativeTurtles - a community for developers & tech enthusiasts.
  • Share projects, get code reviewed, and talk tech without the noise.
  • New here? Introduce yourself in the Introductions forum!
Hello There, Guest! Login Register


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Title: [Tutorial] Essential Git commands and workflows every developer should know
Threaded Mode
#1
Git is one of those tools where most people learn just enough to get by and then stay at that level forever. Here's a reference for the commands that go beyond the basics and are worth knowing.

The stuff everyone knows
Code:
git clone, git add, git commit, git push, git pull

Branching properly
Code:
git switch -c feature/my-feature    # create and switch to new branch
git switch main                       # go back to main
git branch -d feature/my-feature      # delete branch after merge

Staging selectively
Code:
git add -p    # interactively choose hunks to stage (very useful)

Fixing mistakes
Code:
git restore --staged file.txt    # unstage a file
git restore file.txt              # discard local changes to a file
git commit --amend --no-edit      # add staged changes to the last commit without changing the message
git reset HEAD~1                  # undo the last commit but keep the changes staged

Investigating history
Code:
git log --oneline --graph --all    # visual branch history
git log -p file.txt                # full history of changes to a file
git blame file.txt                 # who changed each line and when
git diff main...feature            # what changed on feature branch since it diverged from main

Finding regressions
Code:
git bisect start
git bisect bad HEAD           # current commit is broken
git bisect good v1.2.0        # this version was fine
# git tests each midpoint, you mark good/bad until it finds the commit

Stashing work in progress
Code:
git stash                     # save dirty working tree
git stash list                 # see all stashes
git stash pop                  # restore most recent stash

Cleaning up
Code:
git clean -fd                  # delete untracked files and directories (careful - irreversible)

A good Git mental model: commits are snapshots, branches are pointers to commits, and most "scary" commands (reset, rebase) just move these pointers around. Once that clicks, the tool becomes much less mysterious.
Reply
  


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tutorial] SSH keys - setup, security, and useful config tricks Zero Two 0 207 06-22-2026, 02:31 PM
Last Post: Zero Two
  [Tutorial] Setting up a WireGuard VPN on a cheap VPS - complete guide Zero Two 0 187 06-22-2026, 02:02 PM
Last Post: Zero Two
  [Index] Community Tutorial & Resource Index Zero Two 0 219 06-21-2026, 09:42 AM
Last Post: Zero Two

Forum Jump:


Browsing: 2 Guest(s)