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

推荐订阅源

Help Net Security
Help Net Security
Recent Announcements
Recent Announcements
A
About on SuperTechFans
N
News and Events Feed by Topic
I
Intezer
B
Blog
GbyAI
GbyAI
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Project Zero
Project Zero
T
The Blog of Author Tim Ferriss
Blog — PlanetScale
Blog — PlanetScale
阮一峰的网络日志
阮一峰的网络日志
T
Troy Hunt's Blog
TaoSecurity Blog
TaoSecurity Blog
IT之家
IT之家
MyScale Blog
MyScale Blog
The Register - Security
The Register - Security
Cyberwarzone
Cyberwarzone
Y
Y Combinator Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
酷 壳 – CoolShell
酷 壳 – CoolShell
Stack Overflow Blog
Stack Overflow Blog
P
Privacy & Cybersecurity Law Blog
S
Secure Thoughts
MongoDB | Blog
MongoDB | Blog
N
Netflix TechBlog - Medium
Hacker News - Newest:
Hacker News - Newest: "LLM"
G
Google Developers Blog
罗磊的独立博客
博客园 - 聂微东
G
GRAHAM CLULEY
AWS News Blog
AWS News Blog
Google Online Security Blog
Google Online Security Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
C
Check Point Blog
L
Lohrmann on Cybersecurity
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Spread Privacy
Spread Privacy
O
OpenAI News
T
Tor Project blog
P
Privacy International News Feed
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Attack and Defense Labs
Attack and Defense Labs
L
LINUX DO - 最新话题
Forbes - Security
Forbes - Security
云风的 BLOG
云风的 BLOG
C
Cisco Blogs
S
Securelist
博客园_首页

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Git: Version Control For People Who've Lost Code Before
Akhilesh · 2026-05-02 · via DEV Community

You spent three hours on a Python script.

It worked. Everything was perfect.

Then you tried to add one feature. Something broke. You tried to undo it. You could not remember exactly what you changed. You deleted too much. Now nothing works and the working version is gone.

Every programmer has lived this exact moment. Usually more than once.

Git exists so this never happens again.


What Git Actually Is

Git is a version control system. Every time you tell Git to save your work, it takes a snapshot of your entire project at that moment. You can go back to any snapshot at any time.

Not just one undo. Infinite undos, all the way back to the beginning of the project.

But Git is more than undo. It lets multiple people work on the same project without overwriting each other's work. It lets you experiment in a separate branch without touching the main code. It shows you exactly what changed between any two points in time.

Every professional developer uses Git. Every AI project on GitHub uses Git. Every job that involves code expects you to know Git. This is not optional.


Installing Git

Check if it is already installed:

git --version

Enter fullscreen mode Exit fullscreen mode

If not:

# Windows: download from git-scm.com
# Mac:
brew install git

# Ubuntu/Debian:
sudo apt install git

Enter fullscreen mode Exit fullscreen mode

Configure your identity. Git tags every commit with your name and email:

git config --global user.name "Your Name"
git config --global user.email "you@email.com"
git config --global core.editor "code --wait"  # use VS Code as editor

Enter fullscreen mode Exit fullscreen mode

Run these once. They apply to every Git repository on your machine.


The Mental Model: Three Areas

Before commands make sense, understand where your files live in Git's world.

Working Directory: your actual files. Where you write and edit code. Git knows about changes here but has not saved them yet.

Staging Area: a holding area. You choose which changes to include in the next save. Think of it as packing a box before sealing it.

Repository: the saved history. Every commit lives here permanently. This is what Git actually tracks.

The flow is always: edit files → stage the changes you want → commit to save them permanently.

Working Directory  →  git add  →  Staging Area  →  git commit  →  Repository

Enter fullscreen mode Exit fullscreen mode


Starting a Project

mkdir ai_project
cd ai_project
git init

Enter fullscreen mode Exit fullscreen mode

Output:

Initialized empty Git repository in /home/user/ai_project/.git/

Enter fullscreen mode Exit fullscreen mode

git init creates a hidden .git folder inside your project. That folder is the entire repository. Git history, configuration, everything. Never delete or manually edit it.

Check the current state:

git status

Enter fullscreen mode Exit fullscreen mode

Output:

On branch main

No commits yet

nothing to commit (create/copy files and start working)

Enter fullscreen mode Exit fullscreen mode

Empty project. Nothing staged. Nothing committed. Now create a file.

echo "# My AI Project" > README.md
echo "print('Hello, AI')" > main.py

Enter fullscreen mode Exit fullscreen mode

git status

Enter fullscreen mode Exit fullscreen mode

Output:

On branch main

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        README.md
        main.py

nothing added to commit but untracked files present

Enter fullscreen mode Exit fullscreen mode

Git sees both files but they are untracked. It will not save them until you tell it to.


Staging and Committing

Add specific files to staging:

git add README.md
git add main.py

Enter fullscreen mode Exit fullscreen mode

Or add everything at once:

git add .

Enter fullscreen mode Exit fullscreen mode

Check what is staged:

git status

Enter fullscreen mode Exit fullscreen mode

Output:

On branch main

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
        new file:   README.md
        new file:   main.py

Enter fullscreen mode Exit fullscreen mode

Both files are staged. Now commit them:

git commit -m "Initial commit: add README and main script"

Enter fullscreen mode Exit fullscreen mode

Output:

[main (root-commit) a3f9d21] Initial commit: add README and main script
 2 files changed, 2 insertions(+)
 create mode 100644 README.md
 create mode 100644 main.py

Enter fullscreen mode Exit fullscreen mode

The commit is saved. a3f9d21 is the commit hash, a unique identifier for this exact snapshot.

The commit message matters. Write what changed and why, not just what file you touched. "fix bug" is useless. "fix KeyError when loading CSV with missing headers" is useful.


Viewing History

git log

Enter fullscreen mode Exit fullscreen mode

Output:

commit a3f9d21c4e8b1f2a3d5e6f7890ab12cd34ef5678
Author: Your Name <you@email.com>
Date:   Mon Mar 04 14:23:11 2024

    Initial commit: add README and main script

Enter fullscreen mode Exit fullscreen mode

Compact version:

git log --oneline

Enter fullscreen mode Exit fullscreen mode

Output:

a3f9d21 Initial commit: add README and main script

Enter fullscreen mode Exit fullscreen mode

See what changed in a commit:

git show a3f9d21

Enter fullscreen mode Exit fullscreen mode

See differences between current state and last commit:

git diff

Enter fullscreen mode Exit fullscreen mode


Making More Commits

Add some code:

# data_loader.py
import pandas as pd

def load_data(filepath):
    df = pd.read_csv(filepath)
    print(f"Loaded {len(df)} rows")
    return df

Enter fullscreen mode Exit fullscreen mode

git add data_loader.py
git commit -m "Add data loader function with row count logging"

Enter fullscreen mode Exit fullscreen mode

Change something in main.py:

git add main.py
git commit -m "Import and use data loader in main script"

Enter fullscreen mode Exit fullscreen mode

View the full history:

git log --oneline

Enter fullscreen mode Exit fullscreen mode

Output:

c7e91b3 Import and use data loader in main script
d4f82a1 Add data loader function with row count logging
a3f9d21 Initial commit: add README and main script

Enter fullscreen mode Exit fullscreen mode

Three commits. Three save points. You can go back to any of them.


Going Back in Time

See what the project looked like at any commit:

git checkout a3f9d21

Enter fullscreen mode Exit fullscreen mode

Your files change to that earlier state. To come back to the current version:

git checkout main

Enter fullscreen mode Exit fullscreen mode

Undo changes to a file before staging:

git restore main.py

Enter fullscreen mode Exit fullscreen mode

This throws away all unsaved changes to main.py and restores it to the last committed version. Cannot be undone. Use carefully.

Unstage a file you accidentally staged:

git restore --staged main.py

Enter fullscreen mode Exit fullscreen mode


.gitignore: Files Git Should Never Track

Some files should never go into Git. Large data files. Environment variables. API keys. Generated outputs. Python cache files.

Create a .gitignore file in your project root:

# Python
__pycache__/
*.pyc
*.pyo
.env
venv/
.venv/

# Data files
*.csv
*.xlsx
data/raw/
*.db

# Jupyter
.ipynb_checkpoints/

# OS
.DS_Store
Thumbs.db

# IDE
.vscode/
.idea/

# Model files (often large)
*.pkl
*.h5
models/

Enter fullscreen mode Exit fullscreen mode

Once this file exists, Git ignores everything matching these patterns. They will never show up in git status and will never be accidentally committed.

Add and commit the .gitignore file itself:

git add .gitignore
git commit -m "Add gitignore for Python, data files, and editor artifacts"

Enter fullscreen mode Exit fullscreen mode


Branches: Experiment Without Breaking Things

A branch is a parallel version of your project. You create one, make changes, and those changes only exist in that branch until you merge them back.

Create and switch to a new branch:

git branch feature-preprocessing
git checkout feature-preprocessing

Enter fullscreen mode Exit fullscreen mode

Shortcut that does both:

git checkout -b feature-preprocessing

Enter fullscreen mode Exit fullscreen mode

Now you are on the feature branch. Any commits you make here do not affect the main branch. Build your feature, break things, experiment freely.

git add preprocessing.py
git commit -m "Add data preprocessing pipeline with outlier removal"

Enter fullscreen mode Exit fullscreen mode

Switch back to main and check that your new file is not there:

git checkout main
ls

Enter fullscreen mode Exit fullscreen mode

The preprocessing.py file is gone from view. It exists on the feature branch. Main is untouched.

Merge the feature branch into main when you are happy with it:

git merge feature-preprocessing

Enter fullscreen mode Exit fullscreen mode

Output:

Updating c7e91b3..f3a84e2
Fast-forward
 preprocessing.py | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

Enter fullscreen mode Exit fullscreen mode

The feature is now on main. The feature branch can be deleted:

git branch -d feature-preprocessing

Enter fullscreen mode Exit fullscreen mode


The Commands You Use Every Day

git status                          # what is changed
git add .                           # stage everything
git add filename.py                 # stage one file
git commit -m "clear message"       # save staged changes
git log --oneline                   # view history
git diff                            # see unstaged changes
git diff --staged                   # see staged changes
git checkout -b branch-name         # create and switch to branch
git checkout main                   # switch to main
git merge branch-name               # merge branch into current
git restore filename.py             # discard unstaged changes
git restore --staged filename.py    # unstage a file
git stash                           # temporarily save uncommitted work
git stash pop                       # restore stashed work

Enter fullscreen mode Exit fullscreen mode

git stash is underrated. When you are in the middle of something and need to switch branches quickly, stash saves your work in progress without committing it. git stash pop brings it back.


A Common Workflow

This is what a typical working day looks like with Git.

git status                              # see what changed since yesterday
git add analysis.py data_loader.py      # stage the files you worked on
git commit -m "Add feature scaling and handle NaN in loader"

git checkout -b experiment-new-model    # try something risky in isolation
# ... work for a few hours ...
git add model.py
git commit -m "WIP: trying LGBM instead of XGBoost"

# something breaks, want to go back to clean state
git checkout main                       # jump back to stable code
git stash drop                          # or delete the experiment branch
git branch -D experiment-new-model

Enter fullscreen mode Exit fullscreen mode

Commit often. Small commits are easier to understand and easier to undo. A commit with twenty file changes and the message "stuff" is useless. Ten commits with clear messages is professional.


A Resource Worth Reading

Scott Chacon and Ben Straub wrote Pro Git, a complete book on Git available free at git-scm.com/book. Chapters 1 through 3 cover everything in this post plus branching and merging in depth. Chapter 7 covers the advanced tools most professionals do not know. The book is the canonical Git reference and it is completely free. Worth bookmarking and reading chapter by chapter over a few weeks.

Atlassian has a tutorial series called "Learn Git with Bitbucket Cloud" at atlassian.com/git/tutorials that is more visual and beginner-friendly than the official docs. Widely recommended as a starting point. Search "Atlassian Git tutorials."


Try This

Create a new folder called ml_practice. Initialize a Git repository inside it.

Create these files: README.md with a project description, data_loader.py with a function that reads a CSV, utils.py with a helper function, .gitignore that ignores .csv files, __pycache__, and .env.

Make three separate commits with clear messages. Each commit should add or change something meaningful, not just touch a file.

Create a branch called feature-eda. On that branch, add an eda.py file with at least three Pandas operations. Commit it with a clear message.

Switch back to main. Verify eda.py is not there. Merge the feature branch into main. Verify it is there now.

Run git log --oneline and show four commits minimum. The history should tell the story of what you built.


What's Next

Your code is version controlled. Next is GitHub, where that version history becomes visible to the world, shareable with collaborators, and the foundation of your public portfolio. Every project you build from this point forward goes on GitHub.