分支说明
master // 主分支,一般用于发布版本
dev // 开发分支
创建版本
git clone 'url' // 克隆远程仓库代码
git init // git仓库本地化
代码操作
git status // 查看本地文件修改的状态
git diff // 查看具体变更内容
git add . // 将所有改动文件添加到暂存区
git add 'file' // 添加指定文件到暂存区
git commit -m 'message' // 本次提交的说明
git pull // 拉取远程分支代码至本地分支
git push // 当前代码合并至远程仓库
git rm 'file' // 删除指定文件
git rm --cachen 'file' // 停止跟踪文件但不删除
git commit --amend // 修改最后一次提交
git reset --hard HEAD // 撤销所有未提交的修改内容
git checkout HEAD 'file' // 撤销指定文件未提交的内容
git revert 'commit' // 撤销指定的提交
git merge 'branchName' // 当前分支合并指定分支的代码
git rebase 'branchName' // 衍生合并指定分支的代码
git fetch // 获取远程分支
git remote -v // 查看远程仓库版本信息
git remote show 'remoteName' // 查看指定远程版本库信息
git remote add 'remoteName' 'url' // 添加远程版本库
查看历史
git log // 查看提交历史
git log -p 'file' // 查看指定文件的提交历史
git blame 'file' // 以列表的方式查看指定文件的提交历史
分支
git branch // 显示所有本地分支
git checkout 'branch || tag' // 切换到指定分支或者标签
git branch 'branchName' // 创建新分支
git branch -d 'branchName' // 删除本地分支
git tag // 列出所有本地标签
git tag 'tagName' // 基于最新提交创建标签
git tag -d 'tagName' // 删除指定标签