Skip to content

Commit

Permalink
添加git常用操作
Browse files Browse the repository at this point in the history
  • Loading branch information
mrasea committed Mar 30, 2024
1 parent b341a99 commit 04da693
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 3 deletions.
108 changes: 108 additions & 0 deletions docs/tool/git.md
Original file line number Diff line number Diff line change
@@ -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 [email protected]
```

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
```
9 changes: 6 additions & 3 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@ copyright: Copyright &copy; 2024-2024 mrasea</br>The website content is licensed
theme:
name: material
language: zh
features:
- content.code.copy

markdown_extensions:
- pymdownx.superfences
- pymdownx.tabbed:
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
- mkdocs/material.md
- 工具使用:
- tool/git.md

0 comments on commit 04da693

Please sign in to comment.