新建代码库
// 在当前目录新建一个Git代码库
$ git init
// 新建一个目录,将其初始化为Git代码库
$ git init [project-name]
// 下载一个项目和它的整个代码历史http/ssh
$ git clone [url]
配置
// 显示当前的Git配置
$ git config --list
// 编辑Git配置文件
$ git config -e [--global]
// 设置提交代码时的用户信息
$ git config [--global] user.name "[name]"
$ git config [--global] user.email "[email address]"
提交代码系列
// 添加指定文件到暂存区(VSCode可直接操作,点+)
$ git add
$ git add .
// 提交暂存区到仓库区,xxx可代表合并/开发/更新版本等
// -n 代表跳过校验,-a可跳过add那一步操作
$ git commit -n -m "xxx: 提交描述"
// 更新本地代码
$ git pull
// 下载远程仓库所有变动
$ git fetch
// 提交到远程仓库
$ git push
// 本地新建的分支首次提交--set-upstream可用-u替代
$ git push --set-upstream origin branchName
分支
// 新建分支并跳转到该分支
$ git checkout -b branchName
// 合并master分支到当前分支
$ git merge origin master
// 合并当前commitId
$ git cherry-pick commitId
// 删除分支
$ git branch -d branchName