{"id":971,"date":"2021-05-20T07:33:24","date_gmt":"2021-05-20T07:33:24","guid":{"rendered":"http:\/\/www.liutianfeng.com\/?p=971"},"modified":"2023-02-15T02:25:33","modified_gmt":"2023-02-15T02:25:33","slug":"git-%e5%ae%89%e8%a3%85-nginx-http%e4%bb%a3%e7%90%86-%e5%b8%b8%e7%94%a8%e5%91%bd%e4%bb%a4","status":"publish","type":"post","link":"https:\/\/www.liutianfeng.com\/?p=971","title":{"rendered":"Git &#8211; \u5b89\u88c5 Nginx http\u4ee3\u7406 \u5e38\u7528\u547d\u4ee4 gitlab \u524d\u53f0git | git diff"},"content":{"rendered":"<h1>Git\u7684\u5b89\u88c5<\/h1>\n<p>\u53c2\u8003\uff1ahttps:\/\/blog.csdn.net\/name_is_wl\/article\/details\/86705032<\/p>\n<p>\u5728\u8fd9\u91cc\uff0c\u91c7\u7528yum\u76f4\u63a5\u5b89\u88c5\u7684\u65b9\u5f0f\u3002<\/p>\n<p>\u5b89\u88c5\u4f9d\u8d56\u5305\uff1a<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"\">&gt; yum install -y fcgi-devel autoconf libtool automake fcgiwrap  # \u5b89\u88c5\u4f9d\u8d56\uff0cfcgiwrap\u662fhttp\u4ee3\u7406\u7528\u7684\u3002<\/code><\/pre>\n<p>\u5b89\u88c5Git\uff1a<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"\">yum\u5b89\u88c5\uff1a\n&gt; yum install -y git\n\u6e90\u7801\u5b89\u88c5\uff1a\nhttps:\/\/github.com\/git\/git\/releases\/tag\/v2.11.0  # \u4e0b\u8f7d\u6e90\u7801\nmake prefix=\/usr\/local\/git-2.11 all\nmake prefix=\/usr\/local\/git-2.11 install\n&gt; vim \/etc\/profile.d\/git.sh\nexport PATH=$PATH:\/usr\/local\/git-2.11\/bin\n&gt; useradd -m -d \/home\/git -s \/bin\/git-shell git\u00a0\u00a0#\u00a0\u9ed8\u8ba4shell\u6539\u4e3a\/bin\/git-shell\uff0c\u9632\u6b62\u88ab\u66b4\u529bssh\u653b\u51fb\n&gt; grep git \/etc\/passwd\ngit:x:1002:1002::\/home\/git:\/bin\/git-shell\n&gt;\u00a0passwd\u00a0git<\/code><\/pre>\n<h1>Git\u7528Nginx http\u4ee3\u7406<\/h1>\n<p>\u9996\u5148\uff0c\u4e0a\u9762\u5df2\u7ecf\u5b89\u88c5\u5b8c\u4e86fcgiwrap\uff0c\u8fd9\u4e2a\u662f\u5fc5\u987b\u8981\u88c5\u7684\uff0c\u5b98\u65b9\u63d0\u4f9b\u7684\u542f\u52a8\u811a\u672c\uff1a<\/p>\n<p>https:\/\/www.nginx.com\/resources\/wiki\/start\/topics\/examples\/fcgiwrap\/<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"\">&gt; vim \/etc\/init.d\/fcgiwrap\n#!\/usr\/bin\/perl\n\nuse strict;\nuse warnings FATAL =&gt; qw( all );\n\nuse IO::Socket::UNIX;\n\nmy $bin_path = '\/usr\/local\/bin\/fcgiwrap';\nmy $socket_path = $ARGV[0] || '\/tmp\/cgi.sock';\nmy $num_children = $ARGV[1] || 1;\n\nclose STDIN;\n\nunlink $socket_path;\nmy $socket = IO::Socket::UNIX-&gt;new(\n    Local =&gt; $socket_path,\n    Listen =&gt; 100,\n);\n\ndie \"Cannot create socket at $socket_path: $!\\n\" unless $socket;\n\nfor (1 .. $num_children) {\n    my $pid = fork;\n    die \"Cannot fork: $!\" unless defined $pid;\n    next if $pid;\n\n    exec $bin_path;\n    die \"Failed to exec $bin_path: $!\\n\";\n}\n\n&gt; chmod +x \/etc\/init.d\/fcgiwrap\u00a0\u00a0&amp;&amp; \/etc\/init.d\/fcgiwrap\u00a0#\u00a0\u542f\u52a8\u670d\u52a1<\/code><\/pre>\n<p>\u7f16\u8f91\u865a\u62dfserver\uff0c\u6dfb\u52a0git server\u5730\u5740\u914d\u7f6e\uff1a<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"\">&gt; vim \/usr\/local\/nginx\/conf\/conf.d\/git.conf\nserver {\n        listen      8000;\n        server_name localhost;\n        root \/home\/git\/git_repo;\n \n        client_max_body_size 100m;\n \n        auth_basic \"git\";\n        auth_basic_user_file \/usr\/local\/nginx-1.18.0\/conf\/pass.db;\n \n        location ~(\/.*) {\n           fastcgi_pass  unix:\/tmp\/cgi.sock;\n           fastcgi_param SCRIPT_FILENAME   \/usr\/libexec\/git-core\/git-http-backend;\n           fastcgi_param PATH_INFO         $1;\n           fastcgi_param GIT_HTTP_EXPORT_ALL \"\";\n           fastcgi_param GIT_PROJECT_ROOT  \/home\/git\/git_repo;\n           fastcgi_param REMOTE_USER $remote_user;\n           include fastcgi_params;\n        }\n     }\n&gt;\u00a0\/usr\/local\/nginx\/sbin\/nginx -t &amp;&amp; \/usr\/local\/nginx\/sbin\/nginx &amp;\u00a0\u00a0\u00a0#\u00a0\u542f\u52a8Nginx<\/code><\/pre>\n<p>\u5176\u4e2d\u7684pass.db\u6587\u4ef6\u91cc\u7684\u5185\u5bb9\uff0c\u901a\u8fc7\u5728\u5148\u751f\u6210\uff0c\u6216\u8005\u547d\u4ee4\u751f\u6210\uff1a<\/p>\n<p>https:\/\/tool.oschina.net\/htpasswd<\/p>\n<p>\u7b97\u6cd5\u91c7\u7528Crypt (all Unix servers)\uff0c\u8f93\u5165\u7528\u6237\u540d\u5bc6\u7801\u70b9\u51fb\u751f\u6210\uff08\u968f\u673a\u751f\u6210\uff0c\u6bcf\u6b21\u7ed3\u679c\u90fd\u4e0d\u4e00\u6837\uff09\u3002<\/p>\n<p>\u6216\u8005\u91c7\u7528htpasswd\u547d\u4ee4\uff08\u4f9d\u8d56yum install httpd-tools\uff09<\/p>\n<p>\u4f7f\u7528\u65b9\u6cd5\uff1a<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"\">&gt; htpasswd\nUsage:\n\thtpasswd [-cimB25dpsDv] [-C cost] [-r rounds] passwordfile username\n\thtpasswd -b[cmB25dpsDv] [-C cost] [-r rounds] passwordfile username password\n\n\thtpasswd -n[imB25dps] [-C cost] [-r rounds] username\n\thtpasswd -nb[mB25dps] [-C cost] [-r rounds] username password\n -c  Create a new file.\n -n  Don't update file; display results on stdout.\n -b  Use the password from the command line rather than prompting for it.\n -i  Read password from stdin without verification (for script usage).\n -m  Force MD5 encryption of the password (default).\n -2  Force SHA-256 crypt() hash of the password (secure).\n -5  Force SHA-512 crypt() hash of the password (secure).\n -B  Force bcrypt aencryption of the password (very secure).\n -C  Set the computing time used for the bcrypt algorithm\n     (higher is more secure but slower, default: 5, valid: 4 to 31).\n -r  Set the number of rounds used for the SHA-256, SHA-512 algorithms\n     (higher is more secure but slower, default: 5000).\n -d  Force CRYPT encryption of the password (8 chars max, insecure).\n -s  Force SHA-1 encryption of the password (insecure).\n -p  Do not encrypt the password (plaintext, insecure).\n -D  Delete the specified user.\n -v  Verify password for the specified user.\nOn other systems than Windows and NetWare the '-p' flag will probably not work.\nThe SHA-1 algorithm does not use a salt and is less secure than the MD5 algorithm.\n\n&gt; htpasswd -d \/usr\/local\/nginx-1.18.0\/conf\/pass.db git\nNew password: \nRe-type new password: \nWarning: Password truncated to 8 characters by CRYPT algorithm.\nUpdating password for user git\n&gt; cat pass.db \ngit:A\/u4e\/3BOfPH2<\/code><\/pre>\n<p>\u542f\u52a8nginx\uff0c\u6d4b\u8bd5\u4ee3\u7406\u5373\u53ef\u3002<\/p>\n<h1>Git\u5e38\u7528\u547d\u4ee4<\/h1>\n<pre class=\"pure-highlightjs\"><code class=\"\">&gt; git init --bare lius.git   # init\u4e00\u5171\u7a7a\u4ed3\u5e93\nInitialized empty Git repository in \/root\/test\/lius.git\/\n&gt; git clone http:\/\/git@localhost:8000\/lius.git   # \u514b\u9686\uff0c\u80fd\u6210\u529f\u5219\u8bf4\u660ehttp\u4ee3\u7406\u6210\u529f\nCloning into 'lius'...\nPassword for 'http:\/\/git@localhost:8000': \nremote: Counting objects: 47, done.\nremote: Compressing objects: 100% (33\/33), done.\nremote: Total 47 (delta 7), reused 0 (delta 0)\nUnpacking objects: 100% (47\/47), done.\n&gt; ls\nlius\n&gt; cd lius\n&gt; vim src\/main\/java\/com\/test\/jenkinsdemo\/DemoController.java\n&gt; git commit src\/main\/java\/com\/test\/jenkinsdemo\/DemoController.java\nAborting commit due to empty commit message.  # \u4e0d\u53ef\u65e0commit message\n&gt; git commit -m \"First edit...\" src\/main\/java\/com\/test\/jenkinsdemo\/DemoController.java  # \u63d0\u4ea4\uff0c-m\u6307\u5b9acommit message\n[master 128b68b] First edit...\n Committer: root &lt;root@localhost.localdomain&gt;\nYour name and email address were configured automatically based\non your username and hostname. Please check that they are accurate.\nYou can suppress this message by setting them explicitly:\n\n    git config --global user.name \"Your Name\"\n    git config --global user.email you@example.com\n\nAfter doing this, you may fix the identity used for this commit with:\n\n    git commit --amend --reset-author\n\n 1 file changed, 2 insertions(+), 2 deletions(-)\n&gt; git push   # push\u5230master\u5206\u652f\nwarning: push.default is unset; its implicit value is changing in\nGit 2.0 from 'matching' to 'simple'. To squelch this message\nand maintain the current behavior after the default changes, use:\n\n  git config --global push.default matching\n\nTo squelch this message and adopt the new behavior now, use:\n\n  git config --global push.default simple\n\nSee 'git help config' and search for 'push.default' for further information.\n(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode\n'current' instead of 'simple' if you sometimes use older versions of Git)\n\nPassword for 'http:\/\/git@localhost:8000': \nCounting objects: 17, done.\nCompressing objects: 100% (6\/6), done.\nWriting objects: 100% (9\/9), 688 bytes | 0 bytes\/s, done.\nTotal 9 (delta 2), reused 0 (delta 0)\nTo http:\/\/git@localhost:8000\/lius.git\n   bb75489..128b68b  master -&gt; master\n\n&gt; git clone git@localhost:~\/liemer.git  # \u901a\u8fc7ssh\u6765clone\uff0c\u7c7b\u4f3cscp\u7684\u8fdc\u7aef\u8def\u5f84\u683c\u5f0f\nCloning into 'liemer'...\ngit@localhost's password: \nwarning: You appear to have cloned an empty repository.\n\n# git config --system --unset credential.helper   \/\/ \u91cd\u7f6e\u7528\u6237\u767b\u9646\u4fe1\u606f\n# git config --global credential.helper store        \/\/ \u4fdd\u5b58\u7528\u6237\u767b\u9646\u4fe1\u606f\n<\/code><\/pre>\n<h1>Gitlab\u642d\u5efa<\/h1>\n<p>https:\/\/www.cnblogs.com\/Alex-qiu\/p\/7845626.html<\/p>\n<h1>Git diff<\/h1>\n<p>git diff\u53ef\u4ee5\u5bf9\u6bd4\u51fa\u4e24\u6b21commit_id\u4e4b\u95f4\u7684\u5dee\u5f02, \u901a\u5e38\u7528\u4e8e\u6bd4\u5bf9\u589e\u91cf\u66f4\u65b0.<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"\"># git diff --name-only --diff-filter=[(A|C|D|M|R|T|U|X|B)\u2026[*]]   # \u6dfb\u52a0\u5404\u79cd\u8fc7\u6ee4\u5668\nAdded (A): \u65b0\u589e\nCopied (C): \u590d\u5236\nDeleted (D): \u5220\u9664\nModified (M): \u4fee\u6539\nRenamed (R): \u91cd\u547d\u540d\nHave their type (i.e. regular file, symlink, submodule, \u2026) changed (T): \u5c5e\u6027\u4fee\u6539\nUnmerged (U): \u672a\u5408\u5e76\u7684\nUnknown (X): \u672a\u77e5\u7684\nHave had their pairing Broken (B): ..\u635f\u574f\u7684, \u4e0d\u77e5\u9053\u600e\u4e48\u7ffb\u8bd1...\n\n# git diff --name-only --diff-filter=MA  # \u5e38\u7528\u7684\u662f\u4fee\u6539\u548c\u65b0\u589e\u7684\n\n\u9047\u5230\u8fc7\u4e00\u4e2a\u62a5\u9519\uff1a\n# git diff --diff-filter=MA --name-only d8d9cf8c182fbb0641e3db848be3650019809cd4 b40a8301d427e099de3dea2824badc5b2eed30db\nerror: Could not access 'd8d9cf8c182fbb0641e3db848be3650019809cd4\n\u8fd9\u4e2a\u662f\u56e0\u4e3a\u6ca1\u6709\u5728Git\u6b63\u786e\u7684\u76ee\u5f55\u91cc\u9762\uff0ccd\u5230\u6709.git\u7684\u6b63\u786e\u76ee\u5f55\u518d\u8bd5\u8bd5<\/code><\/pre>\n<p>Git\u4fbf\u6377\u63d0\u4ea4\u5c0f\u811a\u672c<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"\">#!\/bin\/bash\nif [ $# -lt 1 ]; then\n    echo \"Usage: .\/`basename $0` 'update files' 'commit information'\"\n    exit\nfi\n\nfunction ECHO() {\n    local TEXT=\"${1}\"; local COLOR_NUM=\"${2}\"\n    local COLOR=\"37\"\n    if [ \"x${COLOR_NUM}\" != \"x\" ]; then\n        COLOR=\"${COLOR_NUM}\"\n    fi\n    echo -e \"\\033[${COLOR}m${TEXT}\\033[0m\"\n}\n\n# \u6dfb\u52a0\u6587\u4ef6\u5230Git\nECHO \"&gt;&gt;&gt; Add files to commit list...\" 33\nfor i in `echo $1`; do\n    if [ ! -e $i ]; then\n        ECHO \"$i not exist...\" 31\n        exit\n    else\n        git add $i\n        if [ $? -ne 0 ]; then\n            ECHO \"Add file failed...\" 31\n            exit\n        else\n            ECHO \"Add file successfully...\" 32\n        fi\n    fi\ndone\n \n# \u63d0\u4ea4\u6587\u4ef6\u5230Git\nECHO \"&gt;&gt;&gt; Commit files to git...\" 33\nif [ ! -z \"$2\" ]; then\n    git commit -m \"$2\"\nelse\n    git commit -m \"Update $1\"\nfi\n\nif [ $? -ne 0 ]; then\n    ECHO \"Commit file failed...\" 31\n    exit\nelse\n    ECHO \"Commit file successfully...\" 32\nfi\n\n# \u62c9\u53d6\u6587\u4ef6\nECHO \"&gt;&gt;&gt; Pull from git...\"\ngit pull\nif [ $? -ne 0 ]; then\n    ECHO \"Pull failed...\" 31\n    exit\nelse\n    ECHO \"Pull successfully...\" 32\nfi\n\n# Push\u6587\u4ef6\u5230Git\nECHO \"&gt;&gt;&gt; Push to git...\" 33\ngit push\nif [ $? -ne 0 ]; then\n    ECHO \"Push failed...\" 31\n    exit\nelse\n    ECHO \"Push successfully...\" 32\nfi<\/code><\/pre>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u8f6c\u8f7d\u8bf7\u6ce8\u660e\uff1a<a href=\"https:\/\/www.liutianfeng.com\">liutianfeng.com<\/a> &raquo; <a href=\"https:\/\/www.liutianfeng.com\/?p=971\">Git &#8211; \u5b89\u88c5 Nginx http\u4ee3\u7406 \u5e38\u7528\u547d\u4ee4 gitlab \u524d\u53f0git | git diff<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>Git\u7684\u5b89\u88c5 \u53c2\u8003\uff1ahttps:\/\/blog.csdn.net\/name_is_wl\/article\/deta [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=\/wp\/v2\/posts\/971"}],"collection":[{"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=971"}],"version-history":[{"count":13,"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=\/wp\/v2\/posts\/971\/revisions"}],"predecessor-version":[{"id":1587,"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=\/wp\/v2\/posts\/971\/revisions\/1587"}],"wp:attachment":[{"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=971"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=971"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=971"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}