[alias]
a = add .
co = checkout
ci = commit
s = status
pl = pull
p = push
l = log --stat
ca = commit -a
b = branch
cm = commit -m
gst = git status
gd = git diff
gl = git pull
gp = git push
glo = git pull origin
gpo = git push origin
gcm = git common -m
gc = git checkout
gcm = git checkout master
gcd = git checkout develop
gb = git branch
ga = git add .
[user]
email = busyhe@qq.com
name = busyhe
[core]
pager =
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
# 当前目录创建git仓库
git init
# 新建目录创建仓库
git init [project-name]
# 查看当前git配置
git config --list
# 编辑git配置文件
git config -e [--global]
# 设置提交代码的commit信息
git config [--global] user.name ""
git config [--global] user.email ""
# 添加文件到暂存区
git add [file] [file]
# 添加目录到暂存区
git add [dir]
# 添加当前目录所有文件到暂存区
git add .
# 删除文件,并将这次删除放入暂存区
git rm [file]
# 停止追踪文件,但文件会保留在工作区
git rm --cached [file]
# 改名文件,并将这次改名放入暂存区
git mv [file-origin] [file-new]
# 提交暂存区到仓库区
git commit -m ""
# 提交暂存区部分文件到仓库区
git commit [file1] [file1] -m ""
# 提交工作区自上次commit变化直接到仓库区
git commit -a
# 提交时显示所有diff信息
git commit -v
# 使用新的commit替换上一次提交,也用来改写上一次的提交信息
git commit --ament -m ""
# 显示所有本地分支
git branch
# 显示所有远程分支
git branch -r
# 显示所有本地和远程分支
git branch -a
# 新建分支
git branch [branch-name]
# 新建分支并指定commit
git branch [branch-name] [commit-id]
# 新建并切换到新分支
git checkout -b [branch-name]
# 切换分支
git checkout [branch-name]
# 建立追踪关系
git branch --set-upstream [branch] [remote-branch]
# or
git branch -u [branch] [remote-branch]
# 合并指定分支到当前分支
git merge [branch]
# 删除本地分支
git branch -d [branch-name]
# 删除远程分支
git push origin --delete [branch-name]
# or
git push origin :[origin-name]
# 列出所有tag
git tag
# 新建tag在当前commit
git tag [tag-name]
# 新建tag在指定commit
git tag [tag-name] [commit-id]
....
# 显示有变更的文件
git status
# 显示当前分支的版本历史
git log
# 显示commit历史,以及每次commit变化的文件
git log --stat
# 搜索提交历史
git log -S [keyword]
# 显示某个文件的版本历史
git log --follow [file]
# or
git whatchanged [file]
# 查看某人提交的信息
git log --author="busyhe"
# 下载远程仓库的所有变动
git fetch
git fetch [remote]
feat:新增功能
fix:bug 修复
docs:文档更新
style:不影响程序逻辑的代码修改(修改空白字符,格式缩进,补全缺失的分号等,没有改变代码逻辑)
refactor:重构代码(既没有新增功能,也没有修复 bug)
perf:性能, 体验优化
test:新增测试用例或是更新现有测试
build:主要目的是修改项目构建系统(例如 glup,webpack,rollup 的配置等)的提交
ci:主要目的是修改项目继续集成流程(例如 Travis,Jenkins,GitLab CI,Circle等)的提交
chore:不属于以上类型
的其他类,比如构建流程, 依赖管理
revert:回滚某个更早之前的提交
git config --global pager.branch false