git log --pretty 作者: rontian 时间: 2020-06-11 分类: Git 评论 ``` git log --pretty=format:'%H' -n 1 %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)](http://linux.die.net/man/1/git-shortlog)或者[git-blame(1)](http://linux.die.net/man/1/git-blame)) %ae: 作者邮箱 %aE: 作者邮箱 (.mailmap对应,详情参照[git-shortlog(1)](http://linux.die.net/man/1/git-shortlog)或者[git-blame(1)](http://linux.die.net/man/1/git-blame)) %ad: 日期 (--date= 制定的格式) %aD: 日期, RFC2822格式 %ar: 日期, 相对格式(1 day ago) %at: 日期, UNIX timestamp %ai: 日期, ISO 8601 格式 %cn: 提交者名字 %cN: 提交者名字 (.mailmap对应,详情参照[git-shortlog(1)](http://linux.die.net/man/1/git-shortlog)或者[git-blame(1)](http://linux.die.net/man/1/git-blame)) %ce: 提交者 email %cE: 提交者 email (.mailmap对应,详情参照[git-shortlog(1)](http://linux.die.net/man/1/git-shortlog)或者[git-blame(1)](http://linux.die.net/man/1/git-blame)) %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 add未commit reset恢复文件 作者: rontian 时间: 2018-10-01 分类: Git 评论 ### git fsck > files.txt 获取到所有悬挂的文件,将悬挂的文件名称存入files.txt中,文件内容如下 ``` dangling blob d6bf40c9f290161c87230787a1056d977d36c821 dangling blob d61f00d8cad3920809f4d992ac3031b3f32e7f10 dangling blob d7af99b5e2ae9a21d534f1965c35a2b572143322 dangling blob d96f555491868caffb665c2dd391108abfcac581 dangling blob da2f86e1710b8539b8047e4452f1ff6cb0e1f211 dangling blob e0dfd04e4d3fcbaa6588c8cbb9e9065609bcb862 dangling blob e06f361eb6d429290806b9f9cd7a0aebce22be4d dangling blob e2bfcf6c21b1b9116459e2213b0bd9b5f52b4b67 dangling blob e23f0b42283d43c029f747596ed573859c917876 dangling blob e3dfe04304e451a9a75a46fd0d052279f601f09d dangling blob f50fc6c14e67a228c4ba9a61b1357c16410e8228 dangling blob f55f1b358726d8f23b1a2e57bee6863387bd7ad4 dangling blob fe4f6f5494085ec15a05838bdf793f3ef0532f5f ``` 删除掉"dangling blob",使其变成 ``` d6bf40c9f290161c87230787a1056d977d36c821 d61f00d8cad3920809f4d992ac3031b3f32e7f10 d7af99b5e2ae9a21d534f1965c35a2b572143322 d96f555491868caffb665c2dd391108abfcac581 da2f86e1710b8539b8047e4452f1ff6cb0e1f211 e0dfd04e4d3fcbaa6588c8cbb9e9065609bcb862 e06f361eb6d429290806b9f9cd7a0aebce22be4d e2bfcf6c21b1b9116459e2213b0bd9b5f52b4b67 e23f0b42283d43c029f747596ed573859c917876 e3dfe04304e451a9a75a46fd0d052279f601f09d f50fc6c14e67a228c4ba9a61b1357c16410e8228 f55f1b358726d8f23b1a2e57bee6863387bd7ad4 fe4f6f5494085ec15a05838bdf793f3ef0532f5f ``` ### 将blob字节文件还原为原文 ```bash #!/bin/bash for line in `cat files.txt` do echo "File:${line}" git show ${line} > files/${line}.txt done ```