Pinned Post

Recent Posts

为某个 git 项目使用指定私钥提交

貌似不能在项目目录中直接配置。
~/.ssh/config 中增加一个 ssh 主机配置:

Host github-id2
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_rsa_id2
    Port 22

然后指定 origin 为配置中的主机:

git remote add origin git@github-id2:path/my-repository.git

git log --pretty 参数

%H: commit hash
%h: 缩短的commit hash
%T: tree hash
%t: 缩短的 tree hash
%P: parent hashes
%p: 缩短的 parent hashes
%an: 作者名字
%aN: mailmap的作者名字 (.mailmap对应,详情参照git-shortlog(1)或者git-blame(1))
%ae: 作者邮箱
%aE: 作者邮箱 (.mailmap对应,详情参照git-shortlog(1)或者git-blame(1))
%ad: 日期 (--date= 制定的格式)
%aD: 日期, RFC2822格式
%ar: 日期, 相对格式(1 day ago)
%at: 日期, UNIX timestamp
%ai: 日期, ISO 8601 格式
%cn: 提交者名字
%cN: 提交者名字 (.mailmap对应,详情参照git-shortlog(1)或者git-blame(1))
%ce: 提交者 email
%cE: 提交者 email (.mailmap对应,详情参照git-shortlog(1)或者git-blame(1))
%cd: 提交日期 (--date= 制定的格式)
%cD: 提交日期, RFC2822格式
%cr: 提交日期, 相对格式(1 day ago)
%ct: 提交日期, UNIX timestamp
%ci: 提交日期, ISO 8601 格式
%d: ref名称
%e: encoding
%s: commit信息标题
%f: sanitized subject line, suitable for a filename
%b: commit信息内容
%N: commit notes
%gD: reflog selector, e.g., refs/stash@{1}
%gd: shortened reflog selector, e.g., stash@{1}
%gs: reflog subject
%Cred: 切换到红色
%Cgreen: 切换到绿色
%Cblue: 切换到蓝色
%Creset: 重设颜色
%C(...): 制定颜色, as described in color.branch.* config option
%m: left, right or boundary mark
%n: 换行
%%: a raw %
%x00: print a byte from a hex code
%w([[,[,]]]): switch line wrapping, like the -w option of git-shortlog(1).

使用示例:

git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative

为了方便使用可以把它命名为 git 别名:

git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"

在使用 gitbook pdf ./ ./mybook.pdf 导出 pdf 时,提示错误 :”InstallRequiredError: “ebook-convert” is not installed.” 按提示前往 https://calibre-ebook.com 下载 Calibre 后,需要创建软链接:ln -s /Applications/calibre.app/Contents/MacOS/ebook-convert /usr/local/bin

git 将当前仓库的 branch_a 分支导出(归档)到 branch_a.zip

git archive --format zip --output "./branch_a.zip" branch_a

Gource ( http://gource.io/ https://github.com/acaudwell/Gource ) 可以将指定 git 项目提交历史以组织成视频形式展示。