{"id":4428,"date":"2022-03-20T00:21:36","date_gmt":"2022-03-19T16:21:36","guid":{"rendered":"https:\/\/egonlin.com\/?p=4428"},"modified":"2022-03-20T00:21:36","modified_gmt":"2022-03-19T16:21:36","slug":"%e7%ac%ac%e4%b9%9d%e7%ab%a0%ef%bc%9a-gitignore%e6%96%87%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/egonlin.com\/?p=4428","title":{"rendered":"\u7b2c\u4e5d\u7ae0\uff1a.gitignore\u6587\u4ef6"},"content":{"rendered":"<h1>\u5ffd\u7565\u67d0\u4e9b\u6587\u4ef6\u540d<\/h1>\n<p>\u6709\u4e9b\u65f6\u5019\uff0c\u4f60\u5fc5\u987b\u628a\u67d0\u4e9b\u6587\u4ef6\u653e\u5230Git\u5de5\u4f5c\u76ee\u5f55\u4e2d\uff0c\u4f46\u53c8\u4e0d\u80fd\u63d0\u4ea4\u5b83\u4eec\uff0c\u6bd4\u5982\u4fdd\u5b58\u4e86\u6570\u636e\u5e93\u5bc6\u7801\u7684\u914d\u7f6e\u6587\u4ef6\u5566<\/p>\n<p>\u5728Git\u5de5\u4f5c\u533a\u7684\u6839\u76ee\u5f55\u4e0b(\u5373.git\u7684\u7236\u76ee\u5f55\u4e0b)\u521b\u5efa\u4e00\u4e2a\u7279\u6b8a\u7684<code>.gitignore<\/code>\u6587\u4ef6\uff0c\u7136\u540e\u628a\u8981\u5ffd\u7565\u7684\u6587\u4ef6\u540d\u586b\u8fdb\u53bb\uff0c\u5728commit\u65f6Git\u5c31\u4f1a\u81ea\u52a8\u5ffd\u7565\u8fd9\u4e9b\u6587\u4ef6\u3002<\/p>\n<p>\u4e0d\u9700\u8981\u4ece\u5934\u5199<code>.gitignore<\/code>\u6587\u4ef6\uff0cGitHub\u5df2\u7ecf\u4e3a\u6211\u4eec\u51c6\u5907\u4e86\u5404\u79cd\u914d\u7f6e\u6587\u4ef6\uff0c\u53ea\u9700\u8981\u7ec4\u5408\u4e00\u4e0b\u5c31\u53ef\u4ee5\u4f7f\u7528\u4e86\u3002\u6240\u6709\u914d\u7f6e\u6587\u4ef6\u53ef\u4ee5\u76f4\u63a5\u5728\u7ebf\u6d4f\u89c8\uff1a<a href=\"https:\/\/github.com\/github\/gitignore\">https:\/\/github.com\/github\/gitignore<\/a><\/p>\n<p>\u5ffd\u7565\u6587\u4ef6\u7684\u539f\u5219\u662f\uff1a<\/p>\n<ol>\n<li>\u5ffd\u7565\u64cd\u4f5c\u7cfb\u7edf\u81ea\u52a8\u751f\u6210\u7684\u6587\u4ef6\uff0c\u6bd4\u5982\u7f29\u7565\u56fe\u7b49\uff1b<\/li>\n<li>\u5ffd\u7565\u7f16\u8bd1\u751f\u6210\u7684\u4e2d\u95f4\u6587\u4ef6\u3001\u53ef\u6267\u884c\u6587\u4ef6\u7b49\uff0c\u4e5f\u5c31\u662f\u5982\u679c\u4e00\u4e2a\u6587\u4ef6\u662f\u901a\u8fc7\u53e6\u4e00\u4e2a\u6587\u4ef6\u81ea\u52a8\u751f\u6210\u7684\uff0c\u90a3\u81ea\u52a8\u751f\u6210\u7684\u6587\u4ef6\u5c31\u6ca1\u5fc5\u8981\u653e\u8fdb\u7248\u672c\u5e93\uff0c\u6bd4\u5982Java\u7f16\u8bd1\u4ea7\u751f\u7684<code>.class<\/code>\u6587\u4ef6\uff1b<\/li>\n<li>\u5ffd\u7565\u4f60\u81ea\u5df1\u7684\u5e26\u6709\u654f\u611f\u4fe1\u606f\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u6bd4\u5982\u5b58\u653e\u53e3\u4ee4\u7684\u914d\u7f6e\u6587\u4ef6\u3002<\/li>\n<\/ol>\n<p>\u4e3e\u4e2a\u4f8b\u5b50\uff1a<\/p>\n<p>\u5047\u8bbe\u4f60\u5728Windows\u4e0b\u8fdb\u884cPython\u5f00\u53d1\uff0cWindows\u4f1a\u81ea\u52a8\u5728\u6709\u56fe\u7247\u7684\u76ee\u5f55\u4e0b\u751f\u6210\u9690\u85cf\u7684\u7f29\u7565\u56fe\u6587\u4ef6\uff0c\u5982\u679c\u6709\u81ea\u5b9a\u4e49\u76ee\u5f55\uff0c\u76ee\u5f55\u4e0b\u5c31\u4f1a\u6709<code>Desktop.ini<\/code>\u6587\u4ef6\uff0c\u56e0\u6b64\u4f60\u9700\u8981\u5ffd\u7565Windows\u81ea\u52a8\u751f\u6210\u7684\u5783\u573e\u6587\u4ef6\uff1a<\/p>\n<pre><code># Windows:\nThumbs.db\nehthumbs.db\nDesktop.ini<\/code><\/pre>\n<p>\u7136\u540e\uff0c\u7ee7\u7eed\u5ffd\u7565Python\u7f16\u8bd1\u4ea7\u751f\u7684<code>.pyc<\/code>\u3001<code>.pyo<\/code>\u3001<code>dist<\/code>\u7b49\u6587\u4ef6\u6216\u76ee\u5f55\uff1a<\/p>\n<pre><code># Python:\n*.py[cod]\n*.so\n*.egg\n*.egg-info\ndist\nbuild<\/code><\/pre>\n<p>\u52a0\u4e0a\u4f60\u81ea\u5df1\u5b9a\u4e49\u7684\u6587\u4ef6\uff0c\u6700\u7ec8\u5f97\u5230\u4e00\u4e2a\u5b8c\u6574\u7684<code>.gitignore<\/code>\u6587\u4ef6\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<pre><code># Windows:\nThumbs.db\nehthumbs.db\nDesktop.ini\n\n# Python:\n*.py[cod]\n*.so\n*.egg\n*.egg-info\ndist\nbuild\n\n# My configurations:\ndb.ini\ndeploy_key_rsa<\/code><\/pre>\n<p>\u6700\u540e\u4e00\u6b65\u5c31\u662f\u628a<code>.gitignore<\/code>\u4e5f\u63d0\u4ea4\u5230Git\uff0c\u5c31\u5b8c\u6210\u4e86\uff01\u5f53\u7136\u68c0\u9a8c<code>.gitignore<\/code>\u7684\u6807\u51c6\u662f<code>git status<\/code>\u547d\u4ee4\u662f\u4e0d\u662f\u8bf4<code>working directory clean<\/code>\u3002<\/p>\n<p>\u4f7f\u7528Windows\u7684\u7ae5\u978b\u6ce8\u610f\u4e86\uff0c\u5982\u679c\u4f60\u5728\u8d44\u6e90\u7ba1\u7406\u5668\u91cc\u65b0\u5efa\u4e00\u4e2a<code>.gitignore<\/code>\u6587\u4ef6\uff0c\u5b83\u4f1a\u975e\u5e38\u5f31\u667a\u5730\u63d0\u793a\u4f60\u5fc5\u987b\u8f93\u5165\u6587\u4ef6\u540d\uff0c\u4f46\u662f\u5728\u6587\u672c\u7f16\u8f91\u5668\u91cc\u201c\u4fdd\u5b58\u201d\u6216\u8005\u201c\u53e6\u5b58\u4e3a\u201d\u5c31\u53ef\u4ee5\u628a\u6587\u4ef6\u4fdd\u5b58\u4e3a<code>.gitignore<\/code>\u4e86\u3002<\/p>\n<p>\u6709\u4e9b\u65f6\u5019\uff0c\u4f60\u60f3\u6dfb\u52a0\u4e00\u4e2a\u6587\u4ef6\u5230Git\uff0c\u4f46\u53d1\u73b0\u6dfb\u52a0\u4e0d\u4e86\uff0c\u539f\u56e0\u662f\u8fd9\u4e2a\u6587\u4ef6\u88ab<code>.gitignore<\/code>\u5ffd\u7565\u4e86\uff1a<\/p>\n<pre><code>$ git add App.class\nThe following paths are ignored by one of your .gitignore files:\nApp.class\nUse -f if you really want to add them.<\/code><\/pre>\n<p>\u5982\u679c\u4f60\u786e\u5b9e\u60f3\u6dfb\u52a0\u8be5\u6587\u4ef6\uff0c\u53ef\u4ee5\u7528<code>-f<\/code>\u5f3a\u5236\u6dfb\u52a0\u5230Git\uff1a<\/p>\n<pre><code>$ git add -f App.class<\/code><\/pre>\n<p>\u6216\u8005\u4f60\u53d1\u73b0\uff0c\u53ef\u80fd\u662f<code>.gitignore<\/code>\u5199\u5f97\u6709\u95ee\u9898\uff0c\u9700\u8981\u627e\u51fa\u6765\u5230\u5e95\u54ea\u4e2a\u89c4\u5219\u5199\u9519\u4e86\uff0c\u53ef\u4ee5\u7528<code>git check-ignore<\/code>\u547d\u4ee4\u68c0\u67e5\uff1a<\/p>\n<pre><code>$ git check-ignore -v App.class\n.gitignore:3:*.class    App.class<\/code><\/pre>\n<p>Git\u4f1a\u544a\u8bc9\u6211\u4eec\uff0c<code>.gitignore<\/code>\u7684\u7b2c3\u884c\u89c4\u5219\u5ffd\u7565\u4e86\u8be5\u6587\u4ef6\uff0c\u4e8e\u662f\u6211\u4eec\u5c31\u53ef\u4ee5\u77e5\u9053\u5e94\u8be5\u4fee\u8ba2\u54ea\u4e2a\u89c4\u5219\u3002<\/p>\n<h3>\u5c0f\u7ed3<\/h3>\n<ul>\n<li>\u5ffd\u7565\u67d0\u4e9b\u6587\u4ef6\u65f6\uff0c\u9700\u8981\u7f16\u5199<code>.gitignore<\/code>\uff1b<\/li>\n<li><code>.gitignore<\/code>\u6587\u4ef6\u672c\u8eab\u8981\u653e\u5230\u7248\u672c\u5e93\u91cc\uff0c\u5e76\u4e14\u53ef\u4ee5\u5bf9<code>.gitignore<\/code>\u505a\u7248\u672c\u7ba1\u7406\uff01<\/li>\n<\/ul>\n<p>ps<\/p>\n<p>\u5728pycharm\u4e2d\u4f7f\u7528gitignore\u529f\u80fd\u4e5f\u9700\u8981\u5b89\u88c5\u63d2\u4ef6:gitignore<\/p>\n<p>\u5b89\u88c5\u5b8c\u6210\u540e\u76f4\u63a5new\u65b0\u5efa.ignore\u6587\u4ef6\u5373\u53ef<\/p>\n<p>\u6ce8\u610f\uff1a\u5df2\u7ecf\u5728\u5f53\u524d\u7248\u5e93\u4e2d\u7684\u6587\u4ef6\uff0c\u5373\u4fbf\u52a0\u5165\u4e86.gitignore\u4e2d\u4e5f\u6ca1\u7528\uff0c\u4e5f\u4f1a\u88ab\u7ba1\u7406\u63d0\u4ea4<\/p>\n<p>\u6211\u4eec\u9700\u8981\u91cd\u65b0\u63d0\u4ea4\u4e00\u4e2a\u6ca1\u6709\u8be5\u6587\u4ef6\u7684\u7248\u672c\uff0c\u4fdd\u8bc1\u5f53\u524d\u7248\u672c\u5e93\u4e2d\u6ca1\u6709\u8be5\u6587\u4ef6\uff0c\u540e\u7eed\u7684\u63d0\u4ea4\u624d\u4f1a\u5ffd\u7565\u8be5\u6587\u4ef6\u7684\u5185\u5bb9<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5ffd\u7565\u67d0\u4e9b\u6587\u4ef6\u540d \u6709\u4e9b\u65f6\u5019\uff0c\u4f60\u5fc5\u987b\u628a\u67d0\u4e9b\u6587\u4ef6\u653e\u5230Git\u5de5\u4f5c\u76ee\u5f55\u4e2d\uff0c\u4f46\u53c8\u4e0d\u80fd\u63d0\u4ea4\u5b83\u4eec\uff0c\u6bd4\u5982\u4fdd\u5b58\u4e86\u6570\u636e\u5e93\u5bc6\u7801\u7684\u914d\u7f6e\u6587 [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[274,336],"tags":[],"_links":{"self":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts\/4428"}],"collection":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4428"}],"version-history":[{"count":0,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts\/4428\/revisions"}],"wp:attachment":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4428"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4428"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4428"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}