Git常用命令 - luoml/spring-cloud-example GitHub Wiki
一行显示分支合并历史、缩略提交校验码 (SHA-1)
git log --graph --pretty=oneline --abbrev-commit
查看最近 n 次提交历史记录 ( n 为正整数)
git log -<n>
查看指定文件的提交信息
git log <fileName>
查看某分支的提交记录
git log <branchName>
显示近两次更新的内容差异
git log -p -2
查看所有合并过的提交历史记录
git log --merges
查看所有未被合并过的提交信息
git log --no-merges
筛选出所有包含 bug 的提交日志
git log --grep=bug
一行显示自 2017-08-20 之后作者为 luoml 的日志记录
git log --oneline --committer=luoml --since="2017-08-20"
查看 commit 的 SHA1 哈希值
git log --pretty=raw
通过一个对象的哈希值查看对象类型(blob、tree、commit、tag)
git cat-file -t <sha1 key>
通过一个对象的哈希值查看对象内容
git cat-file -p <sha1 key>
查看所有分支
git branch -a
查看本地仓库分支
git branch
查看远程仓库分支
git branch -r
创建分支
git branch <branchName>
切换分支
git checkout <branchName>
创建并切换到该分支
git checkout -b <branchName>
查看远程仓库 URL(假设 remote 是 origin)
git remote get-url origin
重新设置远程仓库 URL
git remote set-url origin [new_remote_git_url]