---
title: "暂存文件与代码块"
description: "在 gitā 中暂存整个文件或单个代码块，以树状图或平铺列表查看未暂存和已暂存更改，并在关闭窗口后依然保留未写完的提交信息。"
url: https://getgita.app/zh-hans/features/staging
lang: zh-Hans
---

# 暂存整个文件，或单个代码块

“本地更改”会展示你修改过的内容，清晰区分为已暂存和未暂存两部分，并在一旁显示差异对比。

A live copy of the app is on the page: https://getgita.app/zh-hans/features/staging

## 试试看

1. 点击一个文件查看它的差异对比。
2. 点击差异块上方的 **暂存代码块**，只暂存那一部分更改。
3. 点击 **全部暂存**，输入提交信息，然后点击 **提交已暂存更改**。
4. 使用过滤框旁的按钮在树状视图和平铺列表之间切换。

## 暂存

- **上方未暂存，下方已暂存.** 两个列表完全契合 git 的工作方式。选中一个或多个文件，通过“暂存”或“取消暂存”在两栏间移动。
- **一次一个代码块.** 点击差异中的某个区块，只暂存该代码块，让每次提交都专注于单一改动。
- **树状或平铺列表.** 按文件夹层级查看变更文件，或切换为纯路径列表，并支持按名称过滤。每个文件都标有已修改、新增、删除、重命名或冲突状态。
- **不会丢失的提交信息.** 如果你写了一半提交信息后关闭了标签页、窗口或整个应用，回来时它依然完好无损。每个工作树都有独立的草稿。
- **每个文件都有菜单.** 可以直接打开文件、用其他应用打开、在访达中显示、放弃更改、查看历史记录或复制路径。
- **贮藏.** 附带说明将当前更改暂存到一旁。之后在侧边栏选中该贮藏即可查看内容并应用。

## Questions, answered

### Can I stage only part of a file?

Yes. Click in a block of the diff and **Stage hunk** stages only that part, so one commit holds one idea.

### Do I lose my commit message if I close the window?

No. If you start a commit message and close the tab, the window or the app, it is still there when you come back. There is a draft for each worktree.

[全部功能](https://getgita.app/zh-hans/features.md)

- **下载 macOS 版:** https://github.com/rolottr/gita/releases/latest
- **在 GitHub 上查看:** https://github.com/rolottr/gita

---

Apple, macOS and Mac are trademarks of Apple Inc. Git is a trademark of Software Freedom Conservancy. GitHub is a trademark of GitHub, Inc. Vercel is a trademark of Vercel Inc. Claude is a trademark of Anthropic, PBC. gitā is independent software and is not affiliated with any of them. 问题反馈: https://github.com/rolottr/gita/issues
