Git配置
-------------------
$>git config --system i18n.logoutputencoding gbk
$>git config --system i18n.commitencoding gbk
$>git config --system color.ui true
$>git config --system user.name "HY"
$>git config --system user.email "HY@example.org"
$>git config --system core.logallrefupdates true
$>git config --system alias.s "status -s"
$>git config --system alias.tg "tag --sort=taggerdate --format '%(refname:short) %(taggerdate:short) %(subject)'"
$>git config --system alias.ca "commit --amend --allow-empty --reset-author -aF"
$>git config --system alias.cm "commit -aF"
$>git config --system log.date iso
$>git config -e --system #编辑配置文件.
Git强制切换某个分支
-------------------
$>git checkout -fb <branch name> <tag name>
Git日志
-------------------
$>git log -ps -n [x] #查看最近[x]次提交的修改.
$>git log --since=[x].day #列出最近[x]天的修改.
>git log --since=[x].weeks #列出最近[x]周的修改.
>git log --since=[x].years #列出最近[x]年的修改.
$>git log -s --since=[y].day --committer [x] #列出提交者([x])最近[y]天的修改.
$>git shortlog -n #显示简短的日志信息.
$>git log --graph --pretty=oneline --abbrev-commit #查看分支历史.
$>git reflog #显示本地库HEAD的更改日志.
Git注释格式
-------------------
Added #新加入的需求.
Fixed #修复bug.
Changed #完成的任务.
Updated #完成的任务或者由于第三方模块变化而做的更改.
Issue#[issue number]
Git提交日志
-------------------
步骤1,编辑<commit log>提交日志文件.
$>vi <commit log>
------
title
<Added/Fixed/Changed/Updated>
<desc>(描述):
...
<git status -s>
步骤2,根据<commit log>进行提交.
$>git commit -aF <commit log>
Git注意事项
-------------------
1.Git仓库移动建议使用命令<tar -cvzf name.tar.gz name/>压缩后传输到其他主机然后再解压并使用.
Git清理
-------------------
$>git clean -fdx
Git修改上一次的提交信息
-------------------
$>git commit --amend --allow-empty --reset-author -aF <commit log> #改正上一次的提交记录,此条命令执行后不会新增新的[commit-id]信息;[--amend]是对刚刚的提交进行修补,[--allow-empty]使得空白提交被允许,[--reset-author]是将作者[Author]的ID同步修改,否则只能影响(commit)的ID.
or
$>git ca <commit log>
$>git cm <commit log>
Git创建tag
-------------------
$>git tag -a <tag name> -fF <commit log>
Git对tag输出进行排序
-------------------
$>git tag --sort=taggerdate --format '%(refname:short) %(taggerdate:short) %(subject)'
or
$>git tg
Git显示TAG名字
-------------------
$>git describe
$>git describe <commit id>
$>git name-rev --tags <commit id>
$>git log --oneline --decorate
$>git log <branch name or tag name> --pretty=oneline | git name-rev --tags --stdin
$>git log --oneline -<number> --stat #显示<number>条日志的状态信息.
$>git log -<number> #显示<number>条日志.
Git操作上游TAG
-------------------
$>git remote -v
$>git remote rename <old name> <new name>
$>git remote update #远程版本库的更新.
$>git config remote.<remote name>.skipdefaultupdate true #跳过<remote name>的自动更新.
$>git remote rm <remote name> #删除远程版本库.
$>git ls-remote <origin name> #查看上游tag.
$>git push <origin name> :<tagname> #删除远程版本库中的里程碑.
$>git push <origin name> <tagname> #推送tag到远程版本库.
Git分支
-------------------
$>git branch
$>git branch <branch name>
$>git branch <branch name> <branch name or commit id>
$>git branch -d <branch name>
$>git branch -m <old branch name> <new branch name>
$>git checkout -b <branch name> <branch name or commit id>
Git基于TAG创建分支
-------------------
$>git checkout -b <branch name> <tag name>
Git查看两个分支的提交记录
--------------------
$>git log v4.19.133...v4.19.134
查看代码修改记录
-------------------
文件标注
--------
$>git blame -C -L <起始行,终止行> <文件>
二分查找
--------
$>git bisect start
$>git bisect bad
$>git bisect good <标记名称/TAG>
$>git bisect reset
参考:progit_v2.1.53.pdf <使用 Git 调试>
子模块
--------
参考:progit_v2.1.53.pdf <使用 Git 调试-子模块>
因篇幅问题不能全部显示,请点此查看更多更全内容