Skip to content

提交

一句话解释

提交是 snapshot 的你的项目's files at 时刻 in 时间, 保存到 仓库 history.

用大白话说

提交是 保存 checkpoint. 当你 制作更改到 你的 files, 你 stage 它们使用 git add and 然后保存它们到 history 使用 git commit -m "消息". Each commit records exactly what changed, who changed it, and when.

Commits are the atoms of Git history. They stack on top of each other to form a timeline of your project. You can view the history with git log, compare any two commits with git diff, and jump back to any past commit with git checkout.

A good commit tells a story. The commit message should describe why the change was made, not just what changed — the diff already shows the what. Small, focused commits with clear messages make history easy to read and bugs easy to track down.

示例

bash
# Stage the changed files
git add index.html styles.css

# Commit with a descriptive message
git commit -m "Add hero section to homepage"

# View the commit history
git log --oneline

git 添加 stages 更改; git 提交 保存 它们 到 history 使用 消息; git log shows history.

工作原理

  1. Edit files in your working directory.
  2. Stage the changes with git 添加 — this moves them to the staging area.
  3. Commit with git 提交 -m "消息" — this saves a snapshot to history.
  4. Each commit gets a unique hash (e.g. a1b2c3d) for identification.

相关术语

相关资源

相关课程

相关项目

解读错误信息

用大白话解释常见错误——什么意思、为什么发生、如何修复。

查看错误

← 返回术语表