> For the complete documentation index, see [llms.txt](https://lujw666.gitbook.io/learn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lujw666.gitbook.io/learn/git/00-basic/05-ji-ben-cao-zuo.md).

# 5.Git 基本操作

Git 常用的是以下 6 个命令：git clone、git push、git add 、git commit、git checkout、git pull。

![基本操作](/files/-MRF0QQyFB4ZeDuVKLV7)

说明：

* workspace：工作区
* staging area：暂存区/缓存区
* local repository：或本地仓库
* remote repository：远程仓库

## 创建仓库

| 命令                                                                                    | 说明                 |
| ------------------------------------------------------------------------------------- | ------------------ |
| [git init](/learn/git/00-basic/05-ji-ben-cao-zuo/chuang-jian-cang-ku/01-gitinit.md)   | 初始化仓库              |
| [git clone](/learn/git/00-basic/05-ji-ben-cao-zuo/chuang-jian-cang-ku/02-gitclone.md) | 拷贝一份远程仓库，也就是下载一个项目 |

## 提交与修改

| 命令                                                                                                  | 说明                  |
| --------------------------------------------------------------------------------------------------- | ------------------- |
| [git add](/learn/git/00-basic/05-ji-ben-cao-zuo/ti-jiao-yu-xiu-gai/03-gitadd.md)                    | 添加文件到仓库             |
| [git status](https://github.com/lujw666/learn/blob/develop/git/00-basic/05-command/05-gitstatus.md) | 查看仓库当前的状态，显示有变更的文件  |
| [git diff](/learn/git/00-basic/05-ji-ben-cao-zuo/ti-jiao-yu-xiu-gai/05-gitdiff.md)                  | 比较文件的不同，即暂存区和工作区的差异 |
| [git commit](/learn/git/00-basic/05-ji-ben-cao-zuo/ti-jiao-yu-xiu-gai/06-gitcommit.md)              | 提交暂存区到本地仓库          |
| [git reset](/learn/git/00-basic/05-ji-ben-cao-zuo/ti-jiao-yu-xiu-gai/07-gitreset.md)                | 回退版本                |
| [git rm](/learn/git/00-basic/05-ji-ben-cao-zuo/ti-jiao-yu-xiu-gai/08-gitrm.md)                      | 删除工作区文件             |
| [git mv](/learn/git/00-basic/05-ji-ben-cao-zuo/ti-jiao-yu-xiu-gai/09-gitmv.md)                      | 移动或重命名工作区文件         |

## 分支管理

| 命令                                                                                      | 说明        |
| --------------------------------------------------------------------------------------- | --------- |
| [git branch](/learn/git/00-basic/05-ji-ben-cao-zuo/fen-zhi-guan-li/10-gitbranch.md)     | 显示或创建分支命令 |
| [git checkout](/learn/git/00-basic/05-ji-ben-cao-zuo/fen-zhi-guan-li/11-gitcheckout.md) | 切换分支命令    |
| [git merge](/learn/git/00-basic/05-ji-ben-cao-zuo/fen-zhi-guan-li/12-gitmerge.md)       | 合并分支命令    |

## 远程操作

| 命令                                                                                     | 说明        |
| -------------------------------------------------------------------------------------- | --------- |
| [git remote](/learn/git/00-basic/05-ji-ben-cao-zuo/yuan-cheng-cao-zuo/13-gitremote.md) | 远程仓库操作    |
| [git fetch](/learn/git/00-basic/05-ji-ben-cao-zuo/yuan-cheng-cao-zuo/14-gitfetch.md)   | 从远程获取代码库  |
| [git pull](/learn/git/00-basic/05-ji-ben-cao-zuo/yuan-cheng-cao-zuo/15-gitpull.md)     | 下载远程代码并合并 |
| [git push](/learn/git/00-basic/05-ji-ben-cao-zuo/yuan-cheng-cao-zuo/16-gitpush.md)     | 上传远程代码并合并 |

## 标签

| 命令                                                                      | 说明      |
| ----------------------------------------------------------------------- | ------- |
| [git tag](/learn/git/00-basic/05-ji-ben-cao-zuo/biao-qian/17-gittag.md) | 给提交打上标签 |

## 提交日志

| 命令                                                                               | 说明                 |
| -------------------------------------------------------------------------------- | ------------------ |
| [git log](/learn/git/00-basic/05-ji-ben-cao-zuo/ti-jiao-ri-zhi/18-gitlog.md)     | 查看历史提交记录           |
| [git blame](/learn/git/00-basic/05-ji-ben-cao-zuo/ti-jiao-ri-zhi/19-gitblame.md) | 以列表形式查看指定文件的历史修改记录 |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lujw666.gitbook.io/learn/git/00-basic/05-ji-ben-cao-zuo.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
