This commit is contained in:
许轲 2023-08-20 02:55:45 +08:00
parent c4d1ad91a8
commit 01c59fbe77
4 changed files with 100 additions and 1 deletions

View File

@ -6,4 +6,4 @@
## 文档目录结构 ## 文档目录结构
[中文文档](zh-cn/a_doc.md) [中文文档](zh-cn/doc/doc.md)

View File

@ -2,3 +2,6 @@
本目录是JCNC开发者文档的中文目录。目录内容包括 本目录是JCNC开发者文档的中文目录。目录内容包括
[新人参与开源项目指南](guide.md)
[git常见命令]

96
zh-cn/doc/gitcode.md Normal file
View File

@ -0,0 +1,96 @@
# Git常用命令
1. 克隆Clone 从远程仓库克隆一个项目到本地。
git clone <repository_url>
2. 添加Add 将文件添加到暂存区,准备进行提交。
git add <file_name>
3. 提交Commit 将暂存区的更改提交到本地仓库,并添加提交信息。
git commit -m "Commit message"
4. 推送Push 将本地的提交推送到远程仓库。
git push origin <branch_name>
5. 拉取Pull 从远程仓库拉取最新代码到本地。
git pull origin <branch_name>
6. 分支Branch 创建、切换和查看分支。
* 创建分支:
git branch <new_branch_name>
* 切换分支:
git checkout <branch_name>
* 创建并切换分支Git 2.23+
git switch -c <new_branch_name>
* 查看分支:
git branch
7. 合并Merge 将一个分支的更改合并到另一个分支。
git merge <branch_name>
8. 拉取请求Pull Request
在远程仓库中创建一个拉取请求,请求将你的更改合并到另一个分支。
9. 状态Status 查看工作区和暂存区的状态。
git status
10. 日志Log 查看提交历史记录。
git log
11. 远程仓库Remote 管理远程仓库的连接。
* 添加远程仓库:
git remote add <remote_name> <repository_url>
* 查看远程仓库:
git remote add <remote_name> <repository_url>
12. 撤销Revert 撤销之前的提交。
git revert <commit_hash>
13. 重置Reset 回退到指定提交,可以清空暂存区或工作区。
* 软重置,保留更改:
git reset --soft <commit_hash>
* 混合重置,清空暂存区:
git reset --mixed <commit_hash>
* 硬重置,清空暂存区和工作区(谨慎使用):
git reset --hard <commit_hash>
14. 标签Tag 创建和管理版本标签。
* 创建标签:
git tag <tag_name> <commit_hash>
* 查看标签:
git tag
# 欢迎补充和修改
---