{"id":494,"date":"2025-10-27T14:34:43","date_gmt":"2025-10-27T06:34:43","guid":{"rendered":"https:\/\/satone1008.cn\/?p=494"},"modified":"2025-11-06T14:30:55","modified_gmt":"2025-11-06T06:30:55","slug":"git-alias-%e7%94%a8%e4%bb%a5%e6%89%a7%e8%a1%8c%e4%b8%80%e8%bf%9e%e4%b8%b2%e7%9a%84git%e6%93%8d%e4%bd%9c","status":"publish","type":"post","link":"https:\/\/satone1008.cn\/index.php\/2025\/10\/27\/git-alias-%e7%94%a8%e4%bb%a5%e6%89%a7%e8%a1%8c%e4%b8%80%e8%bf%9e%e4%b8%b2%e7%9a%84git%e6%93%8d%e4%bd%9c\/","title":{"rendered":"Git alias-\u7528\u4ee5\u6267\u884c\u4e00\u8fde\u4e32\u7684git\u64cd\u4f5c"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u4ec0\u4e48\u662fGit alias<\/h2>\n\n\n\n<p>\u5982\u679c\u4f60\u50cf\u6211\u4e00\u6837\u5728\u4f7f\u7528\u547d\u4ee4\u884c\u64cd\u4f5cgit\uff0c\u90a3\u4e48\u5728\u65e5\u5e38\u4f7f\u7528\u4e2d\u7ecf\u5e38\u4f1a\u9047\u5230\u7684\u95ee\u9898\u5c31\u662f\u9700\u8981\u91cd\u590d\u8f93\u5165\u4e00\u7cfb\u5217\u56fa\u5b9a\u7684\u547d\u4ee4\uff0c\u6bd4\u5982 <code>git add<\/code>\u3001<code>git commit<\/code>\u3001<code>git push<\/code> \u7b49\u3002\u968f\u7740\u9879\u76ee\u89c4\u6a21\u548c\u64cd\u4f5c\u9891\u7387\u7684\u589e\u52a0\uff0c\u8fd9\u4e9b\u91cd\u590d\u52a8\u4f5c\u4e0d\u4ec5\u6d6a\u8d39\u65f6\u95f4\uff0c\u4e5f\u5bb9\u6613\u51fa\u9519\u3002<\/p>\n\n\n\n<p>\u5176\u5b9e\uff0cGit \u65e9\u5c31\u4e3a\u6b64\u63d0\u4f9b\u4e86\u89e3\u51b3\u65b9\u6848\u2014\u2014<strong>Git Alias\uff08\u522b\u540d\uff09<\/strong>\u3002<br>\u901a\u8fc7\u4e3a\u5e38\u7528\u547d\u4ee4\u8bbe\u7f6e\u7b80\u77ed\u7684\u522b\u540d\uff0c\u6211\u4eec\u53ef\u4ee5\u5927\u5e45\u63d0\u5347\u64cd\u4f5c\u6548\u7387\uff0c\u8ba9\u5e38\u89c1\u7684 Git \u6d41\u7a0b\u53d8\u5f97\u66f4\u7b80\u6d01\u3001\u66f4\u7b26\u5408\u4e2a\u4eba\u4e60\u60ef\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u600e\u6837\u4f7f\u7528Git alias<\/h2>\n\n\n\n<p>Git alias\uff08\u522b\u540d\uff09\u672c\u8d28\u4e0a\u662f\u5bf9 Git \u547d\u4ee4\u7684\u5feb\u6377\u6620\u5c04\uff0c\u5982\u679c\u60a8\u66fe\u7ecf\u5c1d\u8bd5\u8fc7\u5728CSGO\u7ed1\u5b9a\u4e00\u952e\u8df3\u6295\u90a3\u5e94\u8be5\u4f1a\u5bf9alias\u5f88\u719f\u6089\u3002<br>\u5b83\u5141\u8bb8\u6211\u4eec\u901a\u8fc7\u7b80\u77ed\u7684\u6307\u4ee4\u6765\u8c03\u7528\u4e00\u6761\u6216\u591a\u6761\u5b8c\u6574\u7684 Git \u547d\u4ee4\uff0c\u4ece\u800c\u51cf\u5c11\u8f93\u5165\u91cf\u5e76\u63d0\u5347\u6548\u7387\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u521b\u5efa\u4e00\u4e2a\u522b\u540d<\/h3>\n\n\n\n<p>\u521b\u5efa\u522b\u540d\u7684\u8bed\u6cd5\u975e\u5e38\u7b80\u5355\uff0c\u4f7f\u7528 <code>git config<\/code> \u547d\u4ee4\u5373\u53ef\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git config --global alias.\u522b\u540d \"\u5b8c\u6574\u547d\u4ee4\"<\/code><\/pre>\n\n\n\n<p>\u5176\u4e2d\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>--global<\/code> \u8868\u793a\u5728\u5168\u5c40\u8303\u56f4\u5185\u751f\u6548\uff08\u9002\u7528\u4e8e\u6240\u6709\u4ed3\u5e93\uff09\uff0c<\/li>\n\n\n\n<li>\u5982\u679c\u53bb\u6389 <code>--global<\/code>\uff0c\u5219\u53ea\u5bf9\u5f53\u524d\u4ed3\u5e93\u751f\u6548\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u4f8b\u5982\uff0c\u7ed9 <code>git status<\/code> \u8bbe\u7f6e\u4e00\u4e2a\u7b80\u77ed\u7684\u522b\u540d <code>st<\/code>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git config --global alias.st \"status\"<\/code><\/pre>\n\n\n\n<p>\u4e4b\u540e\uff0c\u53ea\u9700\u8981\u8f93\u5165\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git st<\/code><\/pre>\n\n\n\n<p>\u5c31\u80fd\u5f97\u5230\u548c <code>git status<\/code> \u5b8c\u5168\u4e00\u6837\u7684\u8f93\u51fa\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u7ec4\u5408\u591a\u6761\u547d\u4ee4<\/h3>\n\n\n\n<p>\u522b\u540d\u4e0d\u4ec5\u53ef\u4ee5\u5bf9\u5e94\u4e00\u6761\u547d\u4ee4\uff0c\u4e5f\u53ef\u4ee5\u6267\u884c\u4e00\u8fde\u4e32\u64cd\u4f5c\u3002<br>\u8981\u5b9e\u73b0\u8fd9\u4e00\u70b9\uff0c\u9700\u8981\u5728\u522b\u540d\u524d\u52a0\u4e0a <code>!<\/code>\uff0c\u544a\u8bc9 Git \u8fd9\u662f\u4e00\u4e2a Shell \u547d\u4ee4\u3002<\/p>\n\n\n\n<p>\u4f8b\u5982\uff0c\u6211\u4eec\u5e0c\u671b\u901a\u8fc7\u4e00\u4e2a\u547d\u4ee4\u5b8c\u6210\u4ee5\u4e0b\u52a8\u4f5c\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u6dfb\u52a0\u6240\u6709\u6539\u52a8\uff1b<\/li>\n\n\n\n<li>\u5408\u5e76\u8fdb\u4e0a\u4e00\u6b21\u63d0\u4ea4\uff1b<\/li>\n\n\n\n<li>\u5f3a\u5236\u63a8\u9001\u5230\u8fdc\u7aef\u3002<\/li>\n<\/ol>\n\n\n\n<p>\u53ef\u4ee5\u8fd9\u6837\u5b9a\u4e49\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git config --global alias.fixpush '!git add . &amp;&amp; git commit --amend --no-edit &amp;&amp; git push --force-with-lease'<\/code><\/pre>\n\n\n\n<p>\u73b0\u5728\uff0c\u53ea\u9700\u8f93\u5165\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git fixpush<\/code><\/pre>\n\n\n\n<p>\u5c31\u80fd\u81ea\u52a8\u5b8c\u6210\u6574\u4e2a\u8fc7\u7a0b\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. \u67e5\u770b\u4e0e\u5220\u9664\u522b\u540d<\/h3>\n\n\n\n<p>\u67e5\u770b\u5f53\u524d\u914d\u7f6e\u7684\u6240\u6709\u522b\u540d\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git config --get-regexp alias<\/code><\/pre>\n\n\n\n<p>\u5220\u9664\u67d0\u4e2a\u522b\u540d\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git config --global --unset alias.(\u60f3\u8981\u5220\u9664\u7684alias)\n<strong>\u4e3e\u4f8b\uff1a<\/strong>git config --global --unset alias.fixpush<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5e38\u7528\u7684 Git alias \u63a8\u8350<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u5feb\u901f\u67e5\u770b\u63d0\u4ea4\u8bb0\u5f55<\/h3>\n\n\n\n<p>\u7b80\u6d01\u3001\u56fe\u5f62\u5316\u5730\u67e5\u770b\u63d0\u4ea4\u5386\u53f2\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git config --global alias.lg \"log --oneline --graph --decorate --all\"<\/code><\/pre>\n\n\n\n<p>\u4f7f\u7528\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git lg<\/code><\/pre>\n\n\n\n<p>\u8f93\u51fa\u7ed3\u679c\u4f1a\u4ee5\u5206\u652f\u7ed3\u6784\u548c\u7b80\u77ed\u63d0\u4ea4\u4fe1\u606f\u7684\u5f62\u5f0f\u663e\u793a\uff0c\u6bd4\u9ed8\u8ba4\u7684 <code>git log<\/code> \u66f4\u76f4\u89c2\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u5feb\u901f\u6dfb\u52a0\u5e76\u63d0\u4ea4<\/h3>\n\n\n\n<p>\u5e38\u7528\u4e8e\u4e34\u65f6\u4fdd\u5b58\u5c0f\u6539\u52a8\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git config --global alias.ac '!git add . &amp;&amp; git commit -m'<\/code><\/pre>\n\n\n\n<p>\u4f7f\u7528\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git ac \"update readme\"<\/code><\/pre>\n\n\n\n<p>\u6548\u679c\u7b49\u540c\u4e8e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git add .\ngit commit -m \"update readme\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3. \u4e00\u952e\u4fee\u6b63\u5e76\u63a8\u9001\u4e0a\u6b21\u63d0\u4ea4<\/h3>\n\n\n\n<p>\u5728\u4fee\u6539\u5b8c\u4ee3\u7801\u540e\u66f4\u65b0\u4e0a\u4e00\u6b21\u63d0\u4ea4\uff08\u5305\u542b\u63a8\u9001\uff09\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git config --global alias.fixpush '!git add . &amp;&amp; git commit --amend --no-edit &amp;&amp; git push --force-with-lease'<\/code><\/pre>\n\n\n\n<p>\u4f7f\u7528\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git fixpush<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4. \u5feb\u901f\u64a4\u9500\u4e0a\u6b21\u63d0\u4ea4\uff08\u4fdd\u7559\u6539\u52a8\uff09<\/h3>\n\n\n\n<p>\u5982\u679c\u4e0a\u4e00\u6b21\u63d0\u4ea4\u5199\u9519\u4fe1\u606f\u6216\u5fd8\u8bb0\u52a0\u6587\u4ef6\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git config --global alias.undo 'reset --soft HEAD~1'<\/code><\/pre>\n\n\n\n<p>\u4f7f\u7528\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git undo<\/code><\/pre>\n\n\n\n<p>\u8fd9\u4f1a\u64a4\u9500\u4e0a\u6b21\u63d0\u4ea4\uff0c\u4f46\u4fdd\u7559\u6539\u52a8\u5185\u5bb9\u5728\u6682\u5b58\u533a\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5. \u81ea\u52a8\u6e05\u7406\u672c\u5730\u65e0\u7528\u5206\u652f<\/h3>\n\n\n\n<p>\u6e05\u7406\u5df2\u88ab\u8fdc\u7a0b\u5220\u9664\u7684\u5206\u652f\u5f15\u7528\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git config --global alias.cleanup '!git fetch -p &amp;&amp; git branch -vv | grep \": gone]\" | awk \"{print \\$1}\" | xargs git branch -d'<\/code><\/pre>\n\n\n\n<p>\u4f7f\u7528\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git cleanup<\/code><\/pre>\n\n\n\n<p>\u8fd9\u80fd\u8ba9\u4f60\u7684\u672c\u5730\u5206\u652f\u5217\u8868\u4fdd\u6301\u5e72\u51c0\u6574\u6d01\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7ed3\u8bed<\/h2>\n\n\n\n<p>Git\u8bf4\u5230\u5e95\u53ea\u662f\u4e00\u6b3e\u5de5\u5177\uff0c\u6211\u4eec\u6700\u7ec8\u7684\u76ee\u6807\u4e0d\u662f\u8bb0\u4f4f\u66f4\u591a Git \u547d\u4ee4\uff0c\u800c\u662f\u8ba9 Git \u8bb0\u4f4f\u4f60\u4e60\u60ef\u7684\u5de5\u4f5c\u65b9\u5f0f\u3002\u800cGit alias \u7684\u610f\u4e49\u5c31\u5728\u4e8e\u8ba9 Git \u53d8\u5f97\u66f4\u8d34\u5408\u4f60\u7684\u601d\u7ef4\u65b9\u5f0f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ec0\u4e48\u662fGit alias \u5982\u679c\u4f60\u50cf\u6211\u4e00\u6837\u5728\u4f7f\u7528\u547d\u4ee4\u884c\u64cd\u4f5cgit\uff0c\u90a3\u4e48\u5728\u65e5\u5e38\u4f7f\u7528\u4e2d\u7ecf\u5e38\u4f1a\u9047\u5230\u7684\u95ee\u9898\u5c31\u662f\u9700\u8981\u91cd\u590d\u8f93 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[19],"class_list":["post-494","post","type-post","status-publish","format-standard","hentry","category-17","tag-19"],"_links":{"self":[{"href":"https:\/\/satone1008.cn\/index.php\/wp-json\/wp\/v2\/posts\/494","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/satone1008.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/satone1008.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/satone1008.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/satone1008.cn\/index.php\/wp-json\/wp\/v2\/comments?post=494"}],"version-history":[{"count":2,"href":"https:\/\/satone1008.cn\/index.php\/wp-json\/wp\/v2\/posts\/494\/revisions"}],"predecessor-version":[{"id":496,"href":"https:\/\/satone1008.cn\/index.php\/wp-json\/wp\/v2\/posts\/494\/revisions\/496"}],"wp:attachment":[{"href":"https:\/\/satone1008.cn\/index.php\/wp-json\/wp\/v2\/media?parent=494"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/satone1008.cn\/index.php\/wp-json\/wp\/v2\/categories?post=494"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/satone1008.cn\/index.php\/wp-json\/wp\/v2\/tags?post=494"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}