{"id":188,"date":"2024-07-12T22:43:06","date_gmt":"2024-07-12T14:43:06","guid":{"rendered":"https:\/\/thereisno.top:4430\/?p=188"},"modified":"2024-07-18T10:26:28","modified_gmt":"2024-07-18T02:26:28","slug":"git%e4%bb%a3%e7%a0%81%e8%a1%8c%e7%bb%9f%e8%ae%a1%e5%91%bd%e4%bb%a4%e9%9b%86","status":"publish","type":"post","link":"https:\/\/thereisno.top\/?p=188","title":{"rendered":"Git\u4ee3\u7801\u884c\u7edf\u8ba1\u547d\u4ee4\u96c6"},"content":{"rendered":"\n<p>\u67e5\u770bgit\u4e0a\u4e2a\u4eba\u4ee3\u7801\u91cf<br>\ngit log &#8211;author=&#8221;username&#8221; &#8211;pretty=tformat: &#8211;numstat | awk &#8216;{ add += $1; subs += $2; loc += $1 &#8211; $2 } END { printf &#8220;added lines: %s, removed lines: %s, total lines: %s\\n&#8221;, add, subs, loc }&#8217; &#8211; <br>\n\u7edf\u8ba1\u6bcf\u4e2a\u4eba\u7684\u589e\u5220\u884c\u6570<br>\ngit log &#8211;format=&#8217;%aN&#8217; | sort -u | while read name; do echo -en &#8220;$name\\t&#8221;; git log &#8211;author=&#8221;$name&#8221; &#8211;pretty=tformat: &#8211;numstat | awk &#8216;{ add += $1; subs += $2; loc += $1 &#8211; $2 } END { printf &#8220;added lines: %s, removed lines: %s, total lines: %s\\n&#8221;, add, subs, loc }&#8217; -; done <br>\n\u67e5\u770b\u4ed3\u5e93\u63d0\u4ea4\u8005\u6392\u540d\u524d 5<br>\ngit log &#8211;pretty=&#8217;%aN&#8217; | sort | uniq -c | sort -k1 -n -r | head -n 5 <br>\n\u8d21\u732e\u8005\u7edf\u8ba1\uff1a<br>\ngit log &#8211;pretty=&#8217;%aN&#8217; | sort -u | wc -l <br>\n\u63d0\u4ea4\u6570\u7edf\u8ba1\uff1a<br>\ngit log &#8211;oneline | wc -l<br>\n\u7edf\u8ba1\u4ee3\u7801\u603b\u884c\u6570\uff1a <br>\nfind . -name &#8220;<em>.m&#8221; -or -name &#8220;<\/em>.h&#8221; -or -name &#8220;<em>.xib&#8221; -or -name &#8220;<\/em>.c&#8221; |xargs grep -v &#8220;^$&#8221;|wc -l<\/p>\n\n\n\n<p>\u7edf\u8ba1\u67d0\u4eba\u7684\u4ee3\u7801\u63d0\u4ea4\u91cf\uff0c\u5305\u62ec\u589e\u52a0\uff0c\u5220\u9664\uff1a<br>\ngit log &#8211;author=&#8221;$(git config &#8211;get user.name)&#8221; &#8211;pretty=tformat: &#8211;numstat | gawk &#8216;{ add += $1 ; subs += $2 ; loc += $1 &#8211; $2 } END { printf &#8220;added lines: %s removed lines : %s total lines: %s\\n&#8221;,add,subs,loc }&#8217; &#8211;<br>\n\u4ed3\u5e93\u63d0\u4ea4\u8005\u6392\u540d\u524d 5\uff08\u5982\u679c\u770b\u5168\u90e8\uff0c\u53bb\u6389 head \u7ba1\u9053\u5373\u53ef\uff09\uff1a<br>\ngit log &#8211;pretty=&#8217;%aN&#8217; | sort | uniq -c | sort -k1 -n -r | head -n 5<br>\n\u4ed3\u5e93\u63d0\u4ea4\u8005\uff08\u90ae\u7bb1\uff09\u6392\u540d\u524d 5\uff1a\u8fd9\u4e2a\u7edf\u8ba1\u53ef\u80fd\u4e0d\u4f1a\u592a\u51c6\uff0c\u56e0\u4e3a\u5f88\u591a\u4eba\u6709\u4e0d\u540c\u7684\u90ae\u7bb1\uff0c\u4f46\u4f1a\u4f7f\u7528\u76f8\u540c\u7684\u540d\u5b57<br>\ngit log &#8211;pretty=format:%ae | gawk &#8212; &#8216;{ ++c[$0]; } END { for(cc in c) printf &#8220;%5d %s\\n&#8221;,c[cc],cc; }&#8217; | sort -u -n -r | head -n 5 <br>\n\u8d21\u732e\u8005\u7edf\u8ba1\uff1a<br>\ngit log &#8211;pretty=&#8217;%aN&#8217; | sort -u | wc -l<br>\n\u63d0\u4ea4\u6570\u7edf\u8ba1\uff1a<br>\ngit log &#8211;oneline | wc -l <br>\n\u6dfb\u52a0\u6216\u4fee\u6539\u7684\u4ee3\u7801\u884c\u6570\uff1a<br>\ngit log &#8211;stat|perl -ne &#8216;END { print $c } $c += $1 if \/(\\d+) insertions\/;<\/p>\n\n\n\n<p>git log \u53c2\u6570\u8bf4\u660e\uff1a<br>\n&#8211;author   \u6307\u5b9a\u4f5c\u8005<br>\n&#8211;stat   \u663e\u793a\u6bcf\u6b21\u66f4\u65b0\u7684\u6587\u4ef6\u4fee\u6539\u7edf\u8ba1\u4fe1\u606f\uff0c\u4f1a\u5217\u51fa\u5177\u4f53\u6587\u4ef6\u5217\u8868<br>\n&#8211;shortstat    \u7edf\u8ba1\u6bcf\u4e2acommit \u7684\u6587\u4ef6\u4fee\u6539\u884c\u6570\uff0c\u5305\u62ec\u589e\u52a0\uff0c\u5220\u9664\uff0c\u4f46\u4e0d\u5217\u51fa\u6587\u4ef6\u5217\u8868\uff1a  <br>\n&#8211;numstat   \u7edf\u8ba1\u6bcf\u4e2acommit \u7684\u6587\u4ef6\u4fee\u6539\u884c\u6570\uff0c\u5305\u62ec\u589e\u52a0\uff0c\u5220\u9664\uff0c\u5e76\u5217\u51fa\u6587\u4ef6\u5217\u8868\uff1a<\/p>\n\n\n\n<p>-p \u9009\u9879\u5c55\u5f00\u663e\u793a\u6bcf\u6b21\u63d0\u4ea4\u7684\u5185\u5bb9\u5dee\u5f02\uff0c\u7528 -2 \u5219\u4ec5\u663e\u793a\u6700\u8fd1\u7684\u4e24\u6b21\u66f4\u65b0<br>\n       \u4f8b\u5982\uff1agit log -p  -2<br>\n&#8211;name-only \u4ec5\u5728\u63d0\u4ea4\u4fe1\u606f\u540e\u663e\u793a\u5df2\u4fee\u6539\u7684\u6587\u4ef6\u6e05\u5355<br>\n&#8211;name-status \u663e\u793a\u65b0\u589e\u3001\u4fee\u6539\u3001\u5220\u9664\u7684\u6587\u4ef6\u6e05\u5355<br>\n&#8211;abbrev-commit \u4ec5\u663e\u793a SHA-1 \u7684\u524d\u51e0\u4e2a\u5b57\u7b26\uff0c\u800c\u975e\u6240\u6709\u7684 40 \u4e2a\u5b57\u7b26<br>\n&#8211;relative-date \u4f7f\u7528\u8f83\u77ed\u7684\u76f8\u5bf9\u65f6\u95f4\u663e\u793a\uff08\u6bd4\u5982\uff0c\u201c2 weeks ago\u201d\uff09<br>\n&#8211;graph \u663e\u793a ASCII \u56fe\u5f62\u8868\u793a\u7684\u5206\u652f\u5408\u5e76\u5386\u53f2<br>\n&#8211;pretty \u4f7f\u7528\u5176\u4ed6\u683c\u5f0f\u663e\u793a\u5386\u53f2\u63d0\u4ea4\u4fe1\u606f\u3002\u53ef\u7528\u7684\u9009\u9879\u5305\u62ec oneline\uff0cshort\uff0cfull\uff0cfuller \u548c format\uff08\u540e\u8ddf\u6307\u5b9a\u683c\u5f0f\uff09<br>\n       \u4f8b\u5982\uff1a git log &#8211;pretty=oneline ; git log &#8211;pretty=short ; git log &#8211;pretty=full ; git log &#8211;pretty=fuller<br>\n&#8211;pretty=tformat:   \u53ef\u4ee5\u5b9a\u5236\u8981\u663e\u793a\u7684\u8bb0\u5f55\u683c\u5f0f\uff0c\u8fd9\u6837\u7684\u8f93\u51fa\u4fbf\u4e8e\u540e\u671f\u7f16\u7a0b\u63d0\u53d6\u5206\u6790<br>\n       \u4f8b\u5982\uff1agit log &#8211;pretty=format:&#8221;&#8221;%h &#8211; %an, %ar : %s&#8221;&#8221;<br>\n       \u4e0b\u9762\u5217\u51fa\u4e86\u5e38\u7528\u7684\u683c\u5f0f\u5360\u4f4d\u7b26\u5199\u6cd5\u53ca\u5176\u4ee3\u8868\u7684\u610f\u4e49\u3002                   <br>\n       \u9009\u9879       \u8bf4\u660e                  <br>\n       %H      \u63d0\u4ea4\u5bf9\u8c61\uff08commit\uff09\u7684\u5b8c\u6574\u54c8\u5e0c\u5b57\u4e32               <br>\n       %h      \u63d0\u4ea4\u5bf9\u8c61\u7684\u7b80\u77ed\u54c8\u5e0c\u5b57\u4e32               <br>\n       %T      \u6811\u5bf9\u8c61\uff08tree\uff09\u7684\u5b8c\u6574\u54c8\u5e0c\u5b57\u4e32                   <br>\n       %t      \u6811\u5bf9\u8c61\u7684\u7b80\u77ed\u54c8\u5e0c\u5b57\u4e32                    <br>\n       %P      \u7236\u5bf9\u8c61\uff08parent\uff09\u7684\u5b8c\u6574\u54c8\u5e0c\u5b57\u4e32               <br>\n       %p      \u7236\u5bf9\u8c61\u7684\u7b80\u77ed\u54c8\u5e0c\u5b57\u4e32                   <br>\n       %an     \u4f5c\u8005\uff08author\uff09\u7684\u540d\u5b57              <br>\n       %ae     \u4f5c\u8005\u7684\u7535\u5b50\u90ae\u4ef6\u5730\u5740                <br>\n       %ad     \u4f5c\u8005\u4fee\u8ba2\u65e5\u671f\uff08\u53ef\u4ee5\u7528 -date= \u9009\u9879\u5b9a\u5236\u683c\u5f0f\uff09                   <br>\n       %ar     \u4f5c\u8005\u4fee\u8ba2\u65e5\u671f\uff0c\u6309\u591a\u4e45\u4ee5\u524d\u7684\u65b9\u5f0f\u663e\u793a                    <br>\n       %cn     \u63d0\u4ea4\u8005(committer)\u7684\u540d\u5b57                <br>\n       %ce     \u63d0\u4ea4\u8005\u7684\u7535\u5b50\u90ae\u4ef6\u5730\u5740                    <br>\n       %cd     \u63d0\u4ea4\u65e5\u671f                <br>\n       %cr     \u63d0\u4ea4\u65e5\u671f\uff0c\u6309\u591a\u4e45\u4ee5\u524d\u7684\u65b9\u5f0f\u663e\u793a              <br>\n       %s      \u63d0\u4ea4\u8bf4\u660e  <br>\n&#8211;since  \u9650\u5236\u663e\u793a\u8f93\u51fa\u7684\u8303\u56f4\uff0c<br>\n       \u4f8b\u5982\uff1a git log &#8211;since=2.weeks    \u663e\u793a\u6700\u8fd1\u4e24\u5468\u7684\u63d0\u4ea4<br>\n       \u9009\u9879 \u8bf4\u660e                <br>\n       -(n)    \u4ec5\u663e\u793a\u6700\u8fd1\u7684 n \u6761\u63d0\u4ea4                    <br>\n       &#8211;since, &#8211;after \u4ec5\u663e\u793a\u6307\u5b9a\u65f6\u95f4\u4e4b\u540e\u7684\u63d0\u4ea4\u3002                    <br>\n       &#8211;until, &#8211;before \u4ec5\u663e\u793a\u6307\u5b9a\u65f6\u95f4\u4e4b\u524d\u7684\u63d0\u4ea4\u3002                  <br>\n       &#8211;author \u4ec5\u663e\u793a\u6307\u5b9a\u4f5c\u8005\u76f8\u5173\u7684\u63d0\u4ea4\u3002                <br>\n       &#8211;committer \u4ec5\u663e\u793a\u6307\u5b9a\u63d0\u4ea4\u8005\u76f8\u5173\u7684\u63d0\u4ea4\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u4e00\u4e9b\u4f8b\u5b50\uff1a git log --until=1.minute.ago \/\/ \u4e00\u5206\u949f\u4e4b\u524d\u7684\u6240\u6709 log git log --since=1.day.ago \/\/\u4e00\u5929\u4e4b\u5185\u7684log git log --since=1.hour.ago \/\/\u4e00\u4e2a\u5c0f\u65f6\u4e4b\u5185\u7684 log git log --since=`.month.ago --until=2.weeks.ago \/\/\u4e00\u4e2a\u6708\u4e4b\u524d\u5230\u534a\u4e2a\u6708\u4e4b\u524d\u7684log git<\/code><\/pre>\n\n\n\n<p>log &#8211;since ==2013-08.01 &#8211;until=2013-09-07 \/\/\u67d0\u4e2a\u65f6\u95f4\u6bb5\u7684 log   git blame<br>\n\u770b\u770b\u67d0\u4e00\u4e2a\u6587\u4ef6\u7684\u76f8\u5173\u5386\u53f2\u8bb0\u5f55<br>\n       \u4f8b\u5982\uff1agit blame index.html &#8211;date short<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u67e5\u770bgit\u4e0a\u4e2a\u4eba\u4ee3\u7801\u91cf git log &#8211;author=&#8221;username&#038;#8221 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/thereisno.top\/?p=188\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cGit\u4ee3\u7801\u884c\u7edf\u8ba1\u547d\u4ee4\u96c6\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[23],"class_list":["post-188","post","type-post","status-publish","format-standard","hentry","category-git","tag-git"],"_links":{"self":[{"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/posts\/188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thereisno.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=188"}],"version-history":[{"count":1,"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/posts\/188\/revisions"}],"predecessor-version":[{"id":189,"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/posts\/188\/revisions\/189"}],"wp:attachment":[{"href":"https:\/\/thereisno.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thereisno.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thereisno.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}