From 04da693223471f7d7d014f4491d27a309bf8f8ea Mon Sep 17 00:00:00 2001 From: dinghaiyang Date: Sat, 30 Mar 2024 12:35:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0git=E5=B8=B8=E7=94=A8?= =?UTF-8?q?=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/tool/git.md | 108 +++++++++++++++++++++++++++++++++++++++++++++++ mkdocs.yml | 9 ++-- 2 files changed, 114 insertions(+), 3 deletions(-) create mode 100644 docs/tool/git.md diff --git a/docs/tool/git.md b/docs/tool/git.md new file mode 100644 index 0000000..1e388e8 --- /dev/null +++ b/docs/tool/git.md @@ -0,0 +1,108 @@ +# GIT + +## 参考 + +[gitee命令](https://gitee.com/all-about-git) + +[常用 Git 命令清单](https://www.ruanyifeng.com/blog/2015/12/git-cheat-sheet.html) + + +## 配置 + +1. 查看所有的配置以及它们所在的文件 +``` +git config --list --show-origin +``` + +1. 用户信息 +``` +git config --global user.name "John Doe" +git config --global user.email johndoe@example.com +``` + +1. 检查配置信息 +``` +git config --list +``` + +## 使用 + +### 增加/删除文件 + + +1. 添加指定文件到暂存区 +``` +git add [file1] [file2] ... +``` + +1. 添加当前目录的所有文件到暂存区 +``` +git add . +``` + +1. 删除工作区文件,并且将这次删除放入暂存区 +``` +git rm [file1] [file2] ... +``` + +### 代码提交 + +1. 提交暂存区到仓库区 +``` +git commit -m [message] +``` + +1. 重写上次提交,可重写message +``` +git commit --amend -m [message] +``` + +### 分支 + +1. 列出所有本地分支和远程分支 +``` +git branch -a +``` + +1. 删除分支 +``` +git branch -d [branch-name] +``` + +1. 删除远程分支 +``` +git push origin --delete [branch-name] +git branch -dr [remote/branch] +``` + +### 远程同步 + +1. 下载远程仓库的所有变动 +``` +git fetch [remote] +``` + +1. 显示所有远程仓库 +``` +git remote -v +``` + +1. 增加一个新的远程仓库,并命名 +``` +git remote add [shortname] [url] +``` + +1. 上传本地指定分支到远程仓库 +``` +git push [remote] [branch] +``` + +1. 强行推送当前分支到远程仓库,即使有冲突 +``` +git push [remote] --force +``` + +1. 推送所有分支到远程仓库 +``` +git push [remote] --all +``` \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index 973e2c8..3416083 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -10,6 +10,8 @@ copyright: Copyright © 2024-2024 mrasea
The website content is licensed theme: name: material language: zh + features: + - content.code.copy markdown_extensions: - pymdownx.superfences @@ -17,11 +19,12 @@ markdown_extensions: alternate_style: true nav: - - 介绍: - - index.md + - 介绍: index.md - hello glgo 学习: - hello_algo/index.md - hello_algo/install.md - MkDocs 学习: - mkdocs/index.md - - mkdocs/material.md \ No newline at end of file + - mkdocs/material.md + - 工具使用: + - tool/git.md \ No newline at end of file