来源:最常用的 35 个 Git 命令 - 知乎 (zhihu.com),Git 常用基本命令使用详细大全_git命令行-CSDN博客
git命令https://www.bilibili.com/video/BV1HM411377
新手命令(工作区/仓库区)
git config
git version
git init # 初始化空版本
git clone # 初始化已有版本
git add
git commit
git status
# 分支操作:
git branch # 分支 ls
git branch -d <name> # 删除
git branch <name> # 创建
git checkout <name> # 切换 -b <new_name> 创建And切换
git switch <name> # 建议用switch命令,checkout指令有别的歧义
中级命令(远程仓库)
# 推送
git remote add <name> <url> # 是否会与本地冲突??
git push -u <name> <branch_name> # name 和branchname?
git push --set-upstream <name> <branch_name>
# 下拉
git fetch # 检查
git pull # 直接下载
git stash # 临时存储 https://www.bilibili.com/video/BV193411L7Wn/
git log
git shotlog
git show
git rm <file_name>
高级命令(分支修改)
git rebase
git merge
git bisect # ???
git cherry-pick # https://www.bilibili.com/video/BV1nG411u7zM
git archive # 发包zip
git pull --rebase # 一键重置为远程
git blame # 逐行检查
git tag # 打标签
git verify-commit # 检查
git verify-tag # 检查
git diff HEAD <file_name>
git diff <source branch> <target branch>
git mv <old-file-name> <new-file-name> # ?
git clean # 打扫工作区为空
git reset # ?
一个提交流程
@main: git merge dev
git diff
### 手工修改conflict ###
git add .
git commit -m "merge conflict" # 将会自动提交
git merge --abort # 可以终止
两个经典分支设计
1. 适用于企业开发
2. 适用于开源仓库