惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
Lohrmann on Cybersecurity
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recorded Future
Recorded Future
S
Schneier on Security
I
Intezer
Latest news
Latest news
N
News and Events Feed by Topic
Scott Helme
Scott Helme
T
Threat Research - Cisco Blogs
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
U
Unit 42
量子位
博客园 - 【当耐特】
S
Security @ Cisco Blogs
Google Online Security Blog
Google Online Security Blog
博客园 - 叶小钗
酷 壳 – CoolShell
酷 壳 – CoolShell
NISL@THU
NISL@THU
The Cloudflare Blog
李成银的技术随笔
T
ThreatConnect
L
LINUX DO - 最新话题
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
有赞技术团队
有赞技术团队
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Jina AI
Jina AI
T
Tor Project blog
The Hacker News
The Hacker News
人人都是产品经理
人人都是产品经理
小众软件
小众软件
S
Security Archives - TechRepublic
美团技术团队
博客园 - Franky
Security Latest
Security Latest
J
Java Code Geeks
P
Proofpoint News Feed
V
V2EX
The GitHub Blog
The GitHub Blog
WordPress大学
WordPress大学
Application and Cybersecurity Blog
Application and Cybersecurity Blog
H
Help Net Security
PCI Perspectives
PCI Perspectives
Cyberwarzone
Cyberwarzone
Hugging Face - Blog
Hugging Face - Blog
N
Netflix TechBlog - Medium
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
SecWiki News
SecWiki News
腾讯CDC
爱范儿
爱范儿
D
Docker

DEV Community

I wrapped Claude Code in a zsh function. Here's every decision I almost got wrong. Mobile Game Optimization: A Unity Developer's Checklist Three days I lost chasing a ghost that was already dead on disk Why Too Many Parts Hurt ClickHouse Performance Guardrails for Agent Output: Pluggable Validation Before and After LLM Calls Gemma Forge: Local AI Without the Setup Wall From Half‑dead Prototype to Local‑Only AI Medical Assistant: Rewiring MedClinic with GitHub Copilot Runninig a forkbomb in Jenkins What’s Actually Happening When You Use Git Preventing Recursive Tool Loops in LangChain Agents Building a Rock-Paper-Scissors CLI with TypeScript — Union Types, Conditionals, and Jest Your AI Coding Agent Wastes 80% of Its Context. Fixed That with Graph Theory. Why Flutter Has Become the Go-To Framework for Fintech App Development We built a scripting language just for AI agents. Here's why. Stop building AI inboxes. Build decision layers instead. Meme Monday Why I Built @editora/ui-react? Are AI tools the next level of abstraction in software development? Identity on Solana: Your Wallet Is Your Account One API Call Changed Everything The Internet Career Nobody Talks About Enough: What Is DevRel? Solar Panel Wiring Diagram: Series vs Parallel Hello everyone! Glad to join the dev.to community I Built an AI Agent That Tailors My Resume - Here's How Agents Actually Work I Built a WhatsApp OTP + AI Chatbot Platform for African Businesses MTP Explained — And Why It Matters for Android on Mac Most Beginners Learn Full-Stack Development Backwards GitHub Glow-Up: Open Source, READMEs, Badges, Streaks, Git and gh CLI System Design Cheat Sheet: Concepts Every Developer Should Know Are Junior Developer Roles Actually Dying? A Fresher's Honest Take Using DigitalOcean Droplets as Ephemeral Sandboxes for AI Agents I built a VSCode extension that visualises your code navigation as a call tree — made for legacy codebase pain Vite predev/prebuild: chaining scripts without losing your mind A website to save you from messy browser tabs Dear Web2 Developer... Solana is here calling Postgres JSONB indexes: GIN vs BTREE on the same column The $5 AI That Remembers Everything What are your goals for the week? #180 Zettelkasten for Developers: A Practical Method That Works OpenClaw vs Hermes Agent: Stars, Downloads & Usage 2026 `act` vs. `waitFor` Global Teams Don’t Struggle With Time Zones. They Struggle With Context Python as a JavaScript Dev $5.4 Billion in Damage. 8.5 Million Machines Down. Three YAML Controls Would Have Prevented It. Here's the Structural Analysis. 🚫 Stop Using PN532 V1 for Your NFC Projects (Real Debugging Experience) Probabilistic Graph Neural Inference for smart agriculture microgrid orchestration for extreme data sparsity scenarios Inference Is Becoming the New Steady-State Cost Center Why AI-Generated Code Is Always Good Enough — And Never Great I built a dark admin dashboard template in HTML — no React, no npm, just pure HTML What is the Difference Between Lattice-Based and Hash-Based Signatures? Next.js App Router caching: revalidate, dynamic, and no-store without the folklore Next.js App Router caching: revalidate, dynamic y no-store sin folklore I built Stashly — a full-stack content manager with a rich text editor published: false tags: react, node, mongodb, typescript Why I Started Building React Projects Instead of Just Watching Tutorials ? Every Tool Eventually Becomes Tuesday Nobody Warns You That Real Software Engineering Feels Chaotic Tích hợp VNPay, Stripe trong Odoo 19 BeautifulSoup and Requests for Web Scraping With Python: When Simple Still Works I Was Stuck Debugging React — Then Developer Tools Changed It Buck Converter Ripple: Sizing the Inductor and Capacitor With Confidence AWS Just Made Its MCP Server Generally Available. Here's What It Actually Gives AI Agents. RAMPART Tests Your AI Agents in Dev. What Catches Malicious Tool Calls in Production? Vibe Team Software Engineering: What a Real AI Human Dev Team Workflow Actually Looks Like An npm Package for AI Agent Orchestration Just Shipped With Its Front Door Unlocked. Here's What the CVE Actually Reveals. Microsoft Foundry Just Added CI/CD for AI Agents. Here's What That Actually Changes. The Best Career Insurance Is a Tech Event You Don't Want to Attend Your GitHub Profile Already Tells Recruiters More Than Your Resume. Most Devs Just Don't Surface It. How to Add Execution Budgets to OpenAI Agents SDK Binary Tree Interview Problems: 6 Traversal Patterns, 15 Problems We trained a personal voice DoRA on Qwen3-8B for $1.50 — beat stock model 100% in blind A/B Stop Leaking API Keys: Why I Built a Local-First Vault for Developers 🔐 RAG Explained: How Retrieval-Augmented Generation Actually Works I Built a Fast Async JioSaavn API Wrapper in Python 🎧 chown & chgrp Deploying Your First App on Kubernetes: A Beginner's Guide (Minikube & Kind) Logs in code It's called a PR "review" for a reason DePIN GPU Market: The Failed Job Receipt Developers Should Demand Why Your AI Agent Monitoring is Wrong (And How to Fix It) Lock Down Your Cloud Shares: A Beginner’s Guide to Azure Files Security. Building a Multi-Channel Content Syndication Pipeline with EmDash Plugins Turn Your Phone Into Voice Input for Any React Text Field Which package is bloating your Docker image? Putting Claude Code Under Version Control: Configs Since July, Memory Since April What I Thought DevRel Was vs. What It Actually Is (A Mentee's Honest Take) What I Thought DevRel Was vs. What It Actually Is (A Mentee's Honest Take) 400 Million Tokens Burned Overnight Reviving My Linux Mastery Game from a Merge Conflict — A Finish-Up-A-Thon Comeback Don’t let AI break your collective thinking: a practical guide for engineering teams First Gemma 4 ExecuTorch Deployment on Raspberry Pi 5 — and Why It's 7.7 Slower Than llama.cpp Per-Turn Evaluation: Dynamic Governance for AI Agents The AI Triforce of seed4j: Power, Wisdom, and Courage for Your Dev Agent Your AI agent reports 80% task completion. It fabricated it. Pourquoi les overlays d'accessibilité ne tiennent pas leurs promesses (et ce que la FTC vient d'acter) AI May Break Product-Market Fit in Enterprise Software I’m Building Around the Gap Between AI Output and Repo Truth How to Build a Stripe Customer Portal in Next.js SaaS On-Demand Pricing Feels Safe - Until You See the Bill Building an Internal Developer Portal with Backstage A Production Deployment Guide After the Last Song
Git: Best Practices for Beginners
Guroosh · 2026-05-25 · via DEV Community

Git and GitHub are essential tools for software development, yet many beginners avoid using them properly due to concerns about making mistakes. They worry about accidentally deleting production code, pushing secrets, or exposing poorly written code. However, the real problems that emerge are less dramatic but far more damaging: messy commit histories, abandoned branches, and a lack of context.

This guide outlines simple, reliable practices that keep your workflow clean, predictable, and professional.

Essential Commands to Stay in Control

Git provides numerous commands to check your repository status, and running them causes no harm. In fact, you should develop a habit of using them frequently:

1. git status

  • The most important command, use it obsessively whenever you can.
  • Shows your current branch, what has changed, which files are added, and how your commits compare to the remote origin.

2. git pull

  • Generally safe to run at any time, especially before starting a new task.

3. git diff

  • Useful for reviewing your unstaged changes.

4. git log

  • Useful for reviewing the commit history in your local repository.

Starting with a new Feature

When beginning a new feature, first ensure everything is up to date:

git status     # Ensure you're on the main branch

Enter fullscreen mode Exit fullscreen mode

If you’re not on the main branch, switch to it:

git checkout main

Enter fullscreen mode Exit fullscreen mode

Then continue with:

git pull
# Output example:
# remote: Enumerating objects: 3, done.
# ...
# From github.com:repo/project
#    a3c912d..e71b4ac  main       -> origin/main
# Updating a3c912d..e71b4ac
# Fast-forward
#  README.md | 4 +++-
#  1 file changed, 3 insertions(+), 1 deletion(-)

git pull     # Run again to confirm
# Already up to date.

git log      # Optional, to check the latest commits in your local history

git checkout -b a-new-branch-with-a-unique-name  # -b to create a new branch

git status   # Confirm you're on the new branch

Enter fullscreen mode Exit fullscreen mode

You’re now ready to start coding.

Name your Branches Clearly

Avoid generic names like refactoring, ui_update, or bug_fix.

Branch names should aim to be:

  • Informative: Clearly communicate the purpose
  • Unique: Prevent accidental conflicts with existing branches

A few good examples of branch names:

  • fixing-bug-payment-timeout-using-redis
  • feature/add-user-profile-with-updated-fields
  • task-123--fix-db-connection-issue

If available, include the ticket/task number in the branch to ensure uniqueness and improve traceability.

Commit and Push Frequently to Your Branch

New developers hesitate to push code for various reasons:

  • the code isn’t working yet
  • they’re hiding unfinished work, or
  • they fear accidental merges.

However, pushing frequently to a feature branch is exactly what it’s designed for.

Here’s how to do it:

git status                                 # Ensure you're on the correct branch
git add app/config api/src README.md       # Add only the files you want
git status                                 # Verify what's staged (colored display)
git commit -m "A Good Commit Message"
git push -u origin HEAD

Enter fullscreen mode Exit fullscreen mode

Tip: If you are on the correct branch git push -u origin HEAD will always work, no need to copy and paste the specific branch name.

After pushing, create a Pull Request (PR) immediately:

New developers assume a PR should only be created when the work is finished. This is incorrect. Opening a PR early provides several benefits:

  • A clear, visual summary of all ongoing changes
  • An easy way to track progress as you develop

PRs are not a sign of completion.

In fact, most major Git platforms (GitHub, Azure Repos, etc.) offer Draft PRs to prevent accidental merges and to signal that the work is still in progress.

Option to convert a PR to a Draft PR in Github

Option to convert a PR to a Draft PR in Github

Option to Create a Draft PR in Azure DevOps

Option to Create a Draft PR in Azure DevOps

Avoid adding all files to the staging area

Blindly adding everything with git add . risks pushing:

  • OS-specific hidden files like .DS_Store
  • Temporary artifacts
  • Editor swap files

Instead, intentionally add specific files to the staging area:

git add app/config app/utils api/src README.md

Enter fullscreen mode Exit fullscreen mode

However, as a long term solution .gitignore should be used to avoid staging any unwanted files or folders.

Even with a well-maintained .gitignore, make it a habit to add specific files deliberately rather than relying on git add ..

Closing and Merging the PR

Write Clear, Informative Commit Messages

When it’s time to close the PR, the final commit message must be clean and informative. Individual commit messages on the branch won’t appear in the main history, so focus on the PR’s merge message.

A Good Commit Message explains what changed and why. For example:

  • Bad: “UI changes”
  • Better: “Update to hide unused sidebar buttons to simplify UI”

Tip: Git platforms like GitHub auto-generate merge commit messages and automatically reference PRs using #<number>, which helps maintain a searchable history of closed PRs.

Squash and Merge for Cleaner History

When merging a pull request, use Squash and Merge.

Benefits of Squashing and Merging:

  • Your main branch history remains readable, each feature appears as a single commit.
  • Individual features are easier to revert if needed by just reverting a single squashed commit.
  • Developers can commit frequently on their branch without worrying about cluttering the main branch’s commit history.

Delete the Feature Branch After Merging

After a PR is merged:

  • Delete the feature branch immediately.

Tools like GitHub and Azure Repos retain the PR history, so nothing is lost.

GitHub lets you know that a branch can be safely deleted

GitHub lets you know that a branch can be safely deleted

Azure Repos recommends to delete the source branch when merging a PR

Azure Repos recommeds to delete the source branch when merging a PR

Ideally, only the main branch and active work-in-progress branches should remain in the repository. This keeps the repository clean and prevents confusion by having abandoned branches.

Hope this guide helps.

If you’d like to explore more advanced Git concepts, workflows, and best practices, you can read my Guide for Professional Developers.