1.git
命令 | 简述 |
git --help (简述) 或 git help git (详细) | 查看git命令帮助 |
git <command> --help 或 git help <command> | 查看git子命令帮助 |
git --version | 查看git版本 |
2.git config
命令 | 简述 |
git config --global --list | 查看用户级的所有配置 |
git config --global <key> | 查看用户级的指定配置 |
git config --global <key> <value> | 添加或更改用户级的指定配置 |
git config --global --unset <key> | 删除用户级的指定配置 |
git config --global user.name "<name>" | 添加或更改用户级的用户名配置 |
git config --global user.email "<email>" | 添加或更改用户级的邮箱地址配置 |
git config --global init.defaultBranch "main" | 添加或更改用户级的git init命令的默认分支名称配置 |
3.git clone
命令 | 简述 |
git clone <remote-url> | 克隆远程仓库到当前目录 |
git clone <remote-url> <directory> | 克隆远程仓库到指定目录 |
4.git init
命令 | 简述 |
git init | 将当前目录初始化为一个本地仓库 |
git init <directory> | 将指定目录初始化为一个本地仓库 |
5.git add
命令 | 简述 |
git add . | 添加所有目录(包括子目录)和所有文件到暂存区 |
git add <file> | 添加指定文件到暂存区 |
git add <directory> | 添加指定目录(包括子目录)到暂存区 |
6.git commit
命令 | 简述 |
git commit -m '<msg>' | 提交暂存区到本地仓库,并附加简短描述信息 |
git commit -a -m '<msg>' | 提交工作区(跳过了暂存区)到本地仓库,并附加简短描述信息 |
7.git status
命令 | 简述 |
git status | 查看状态 |
8.git remote
命令 | 简述 |
git remote | 查看所有远程仓库(仅显示<remote-name>) |
git remote -v | 查看所有远程仓库(显示<remote-name>和<remote-url>) |
git remote add <remote-name> <remote-url> | 添加远程仓库,并给远程仓库命名 |
git remote rename <old-remote-name> <new-remote-name> | 更改远程仓库的<remote-name> |
git remote set-url <remote-name> <new-remote-url> | 更改远程仓库的<remote-url> |
git remote remove <remote-name> | 删除远程仓库 |
9.git push
命令 | 简述 |
git push -u <remote-name> <local-branch-name>[:<remote-branch-name>] | 将本地仓库指定分支与远程仓库指定分支关联,并推送本地仓库指定分支到远程仓库指定分支 |
git push | 推送本地仓库当前分支到关联的远程仓库指定分支 |
10.git pull
命令 | 简述 |
git pull | 拉取关联的远程仓库指定分支到本质仓库当前分支 |
原创文章,作者:huoxiaoqiang,如若转载,请注明出处:https://www.huoxiaoqiang.com/experience/linux/31575.html