{"id":2,"date":"2026-03-30T14:20:17","date_gmt":"2026-03-30T06:20:17","guid":{"rendered":"http:\/\/peishop.cn\/?page_id=2"},"modified":"2026-03-30T15:16:37","modified_gmt":"2026-03-30T07:16:37","slug":"sample-page","status":"publish","type":"page","link":"https:\/\/peishop.cn\/index.php\/sample-page\/","title":{"rendered":"Git\u6743\u9650\u8bbe\u8ba1"},"content":{"rendered":"\n<ol>\n<li>\u6838\u5fc3\u5206\u652f\u7ed3\u6784<\/li>\n<\/ol>\n\n\n\n<p>main (\u6216 master) &#8211; \u751f\u4ea7\u73af\u5883\u4ee3\u7801<br>\u251c\u2500\u2500 staging &#8211; \u6d4b\u8bd5\/\u9884\u53d1\u5e03\u73af\u5883<br>\u251c\u2500\u2500 develop &#8211; \u5f00\u53d1\u4e3b\u5206\u652f<br>\u2502 \u251c\u2500\u2500 feature\/* &#8211; \u529f\u80fd\u5206\u652f<br>\u2502 \u251c\u2500\u2500 bugfix\/* &#8211; \u7f3a\u9677\u4fee\u590d\u5206\u652f<br>\u2502 \u2514\u2500\u2500 hotfix\/* &#8211; \u7d27\u6025\u4fee\u590d\u5206\u652f<br>\u2514\u2500\u2500 release\/* &#8211; \u53d1\u5e03\u5206\u652f<\/p>\n\n\n\n<p class=\"has-x-large-font-size\">\u6c38\u4e45\u5206\u652f<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">1. main\/master \u5206\u652f &#8211; \u751f\u4ea7\u73af\u5883<\/h1>\n\n\n\n<h1 class=\"wp-block-heading has-medium-font-size\">\u6743\u9650\uff1a\u53ea\u6709\u7ba1\u7406\u5458\u53ef\u4ee5\u5408\u5e76<\/h1>\n\n\n\n<p>git checkout -b main<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-medium-font-size\">\u4fdd\u62a4\u89c4\u5219\uff1a\u7981\u6b62\u76f4\u63a5push\uff0c\u5fc5\u987b\u901a\u8fc7PR<\/h1>\n\n\n\n<p><\/p>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">2. staging \u5206\u652f &#8211; \u6d4b\u8bd5\/\u9884\u53d1\u5e03\u73af\u5883<\/h1>\n\n\n\n<p>git checkout -b staging<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-medium-font-size\">\u4fdd\u62a4\u89c4\u5219\uff1a\u53ea\u6709\u6d4b\u8bd5\u8d1f\u8d23\u4eba\u53ef\u4ee5\u5408\u5e76<\/h1>\n\n\n\n<p><\/p>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">3. develop \u5206\u652f &#8211; \u5f00\u53d1\u4e3b\u5206\u652f<\/h1>\n\n\n\n<p>git checkout -b develop<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-medium-font-size\">\u4fdd\u62a4\u89c4\u5219\uff1a\u5f00\u53d1\u8005\u53ef\u4ee5\u521b\u5efa\u5206\u652f\uff0c\u5408\u5e76\u9700\u8981\u4ee3\u7801\u5ba1\u67e5<\/h1>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-x-large-font-size\">\u4e34\u65f6\u5206\u652f<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">1. \u529f\u80fd\u5206\u652f feature\/<\/h1>\n\n\n\n<p>git checkout -b feature\/user-authentication<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-medium-font-size\">\u4ecedevelop\u521b\u5efa\uff0c\u5408\u5e76\u56dedevelop<\/h1>\n\n\n\n<h1 class=\"wp-block-heading has-medium-font-size\">\u547d\u540d\uff1afeature\/\u529f\u80fd\u540d\u79f0-issue\u53f7<\/h1>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">2. \u7f3a\u9677\u4fee\u590d\u5206\u652f bugfix\/<\/h1>\n\n\n\n<p>git checkout -b bugfix\/login-error-123<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-medium-font-size\">\u4ecedevelop\u521b\u5efa\uff0c\u5408\u5e76\u56dedevelop<\/h1>\n\n\n\n<h1 class=\"wp-block-heading has-medium-font-size\">\u547d\u540d\uff1abugfix\/\u95ee\u9898\u63cf\u8ff0-issue\u53f7<\/h1>\n\n\n\n<p><\/p>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">3. \u7d27\u6025\u4fee\u590d\u5206\u652f hotfix\/<\/h1>\n\n\n\n<p>git checkout -b hotfix\/critical-security-456<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-medium-font-size\">\u4ecemain\u521b\u5efa\uff0c\u5408\u5e76\u5230main\u548cdevelop<\/h1>\n\n\n\n<h1 class=\"wp-block-heading has-medium-font-size\">\u547d\u540d\uff1ahotfix\/\u95ee\u9898\u63cf\u8ff0-issue\u53f7<\/h1>\n\n\n\n<p><\/p>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">4. \u53d1\u5e03\u5206\u652f release\/<\/h1>\n\n\n\n<p>git checkout -b release\/v1.2.0<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-medium-font-size\">\u4ecedevelop\u521b\u5efa\uff0c\u5408\u5e76\u5230main\u548cdevelop<\/h1>\n\n\n\n<h1 class=\"wp-block-heading has-medium-font-size\">\u547d\u540d\uff1arelease\/\u7248\u672c\u53f7<\/h1>\n\n\n\n<p><\/p>\n\n\n\n<ol>\n<li class=\"has-x-large-font-size\">GitLab\u6743\u9650\u914d\u7f6e\u793a\u4f8b (.gitlab-ci.yml)<\/li>\n<\/ol>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">.gitlab-ci.yml<\/h1>\n\n\n\n<p>stages:<\/p>\n\n\n\n<ul>\n<li>test<\/li>\n\n\n\n<li>build<\/li>\n\n\n\n<li>deploy<\/li>\n<\/ul>\n\n\n\n<p>variables:<br>PRODUCTION_BRANCH: &#8220;main&#8221;<br>STAGING_BRANCH: &#8220;staging&#8221;<br>DEVELOP_BRANCH: &#8220;develop&#8221;<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">\u5206\u652f\u4fdd\u62a4\u89c4\u5219<\/h1>\n\n\n\n<p>workflow:<br>rules:<br>&#8211; if: &#8216;$CI_COMMIT_REF_NAME == $PRODUCTION_BRANCH&#8217;<br>when: manual # \u751f\u4ea7\u90e8\u7f72\u9700\u8981\u624b\u52a8\u89e6\u53d1<br>&#8211; if: &#8216;$CI_COMMIT_REF_NAME == $STAGING_BRANCH&#8217;<br>when: on_success<br>&#8211; if: &#8216;$CI_COMMIT_REF_NAME =~ \/^feature\\\/.*\/&#8217;<br>when: on_success<br>&#8211; if: &#8216;$CI_COMMIT_REF_PROTECTED == &#8220;true&#8221;&#8216;<br>when: never # \u4fdd\u62a4\u5206\u652f\u4e0d\u5141\u8bb8\u76f4\u63a5push<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">\u4ee3\u7801\u8d28\u91cf\u68c0\u67e5<\/h1>\n\n\n\n<p>code_quality:<br>stage: test<br>script:<br>&#8211; echo &#8220;Running code quality checks\u2026&#8221;<br>&#8211; sonar-scanner<br>only:<br>&#8211; develop<br>&#8211; staging<br>&#8211; merge_requests<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">\u5355\u5143\u6d4b\u8bd5<\/h1>\n\n\n\n<p>unit_test:<br>stage: test<br>script:<br>&#8211; echo &#8220;Running unit tests\u2026&#8221;<br>&#8211; phpunit<br>only:<br>&#8211; develop<br>&#8211; staging<br>&#8211; merge_requests<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">\u6784\u5efa<\/h1>\n\n\n\n<p>build:<br>stage: build<br>script:<br>&#8211; echo &#8220;Building application\u2026&#8221;<br>&#8211; npm run build<br>only:<br>&#8211; develop<br>&#8211; staging<br>&#8211; tags<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">\u90e8\u7f72\u5230\u5f00\u53d1\u73af\u5883<\/h1>\n\n\n\n<p>deploy_development:<br>stage: deploy<br>script:<br>&#8211; echo &#8220;Deploying to development\u2026&#8221;<br>&#8211; .\/deploy.sh development<br>only:<br>&#8211; develop<br>environment:<br>name: development<br>url: https:\/\/dev.example.com<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">\u90e8\u7f72\u5230\u6d4b\u8bd5\u73af\u5883<\/h1>\n\n\n\n<p>deploy_staging:<br>stage: deploy<br>script:<br>&#8211; echo &#8220;Deploying to staging\u2026&#8221;<br>&#8211; .\/deploy.sh staging<br>only:<br>&#8211; staging<br>when: manual<br>environment:<br>name: staging<br>url: https:\/\/staging.example.com<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">\u90e8\u7f72\u5230\u751f\u4ea7\u73af\u5883<\/h1>\n\n\n\n<p>deploy_production:<br>stage: deploy<br>script:<br>&#8211; echo &#8220;Deploying to production\u2026&#8221;<br>&#8211; .\/deploy.sh production<br>only:<br>&#8211; main<br>when: manual<br>environment:<br>name: production<br>url: https:\/\/example.com<\/p>\n\n\n\n<p>\u5206\u652f\u4fdd\u62a4\u89c4\u5219<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-x-large-font-size\">Git\u914d\u7f6e\u793a\u4f8b<\/h1>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">1. main\u5206\u652f\u4fdd\u62a4<\/h1>\n\n\n\n<p>git config branch.main.protect true<br>git config branch.main.requireReview 2<br>git config branch.main.requireCI true<br>git config branch.main.noDirectPush true<br>git config branch.main.requireSignedCommits true<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">2. staging\u5206\u652f\u4fdd\u62a4<\/h1>\n\n\n\n<p>git config branch.staging.protect true<br>git config branch.staging.requireReview 1<br>git config branch.staging.requireCI true<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">3. develop\u5206\u652f\u4fdd\u62a4<\/h1>\n\n\n\n<p>git config branch.develop.protect true<br>git config branch.develop.requireReview 1<\/p>\n\n\n\n<p class=\"has-x-large-font-size\">\u529f\u80fd\u5f00\u53d1\u6d41\u7a0b<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">1. \u4ecedevelop\u521b\u5efa\u529f\u80fd\u5206\u652f<\/h1>\n\n\n\n<p>git checkout develop<br>git pull origin develop<br>git checkout -b feature\/user-login-123<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">2. \u5f00\u53d1\u529f\u80fd<\/h1>\n\n\n\n<p>git add .<br>git commit -m &#8220;feat: \u6dfb\u52a0\u7528\u6237\u767b\u5f55\u529f\u80fd #123&#8221;<br>git push origin feature\/user-login-123<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">3. \u521b\u5efaPull Request<\/h1>\n\n\n\n<h1 class=\"wp-block-heading has-medium-font-size\">\u76ee\u6807\u5206\u652f: develop<\/h1>\n\n\n\n<h1 class=\"wp-block-heading has-medium-font-size\">\u6dfb\u52a0\u5ba1\u67e5\u8005: @reviewer1 @reviewer2<\/h1>\n\n\n\n<h1 class=\"wp-block-heading has-medium-font-size\">\u5173\u8054Issue: #123<\/h1>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">4. \u4ee3\u7801\u5ba1\u67e5\u901a\u8fc7\u540e\uff0c\u5408\u5e76\u5230develop<\/h1>\n\n\n\n<p>git checkout develop<br>git merge &#8211;no-ff feature\/user-login-123<br>git branch -d feature\/user-login-123<\/p>\n\n\n\n<p class=\"has-x-large-font-size\">\u53d1\u5e03\u6d41\u7a0b<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">1. \u4ecedevelop\u521b\u5efarelease\u5206\u652f<\/h1>\n\n\n\n<p>git checkout develop<br>git pull origin develop<br>git checkout -b release\/v1.2.0<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">2. \u7248\u672c\u53f7\u66f4\u65b0\u3001\u6587\u6863\u66f4\u65b0<\/h1>\n\n\n\n<h1 class=\"wp-block-heading has-medium-font-size\">\u4fee\u6539version.txt, CHANGELOG.md\u7b49<\/h1>\n\n\n\n<p>git add .<br>git commit -m &#8220;chore: \u51c6\u5907\u53d1\u5e03v1.2.0&#8221;<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">3. \u5408\u5e76\u5230staging\u8fdb\u884c\u6d4b\u8bd5<\/h1>\n\n\n\n<p>git checkout staging<br>git merge &#8211;no-ff release\/v1.2.0<br>git push origin staging<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">4. \u6d4b\u8bd5\u901a\u8fc7\u540e\uff0c\u5408\u5e76\u5230main<\/h1>\n\n\n\n<p>git checkout main<br>git merge &#8211;no-ff release\/v1.2.0<br>git tag -a v1.2.0 -m &#8220;\u53d1\u5e03v1.2.0&#8221;<br>git push origin main &#8211;tags<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">5. \u5408\u5e76\u56dedevelop<\/h1>\n\n\n\n<p>git checkout develop<br>git merge &#8211;no-ff release\/v1.2.0<br>git branch -d release\/v1.2.0<\/p>\n\n\n\n<p class=\"has-x-large-font-size\">\u7d27\u6025\u4fee\u590d\u6d41\u7a0b<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">1. \u4ecemain\u521b\u5efahotfix\u5206\u652f<\/h1>\n\n\n\n<p>git checkout main<br>git pull origin main<br>git checkout -b hotfix\/critical-bug-456<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">2. \u4fee\u590d\u95ee\u9898<\/h1>\n\n\n\n<p>git add .<br>git commit -m &#8220;fix: \u4fee\u590d\u4e25\u91cdbug #456&#8221;<br>git push origin hotfix\/critical-bug-456<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">3. \u5feb\u901f\u6d4b\u8bd5\u540e\u5408\u5e76\u5230main<\/h1>\n\n\n\n<p>git checkout main<br>git merge &#8211;no-ff hotfix\/critical-bug-456<br>git tag -a v1.2.1 -m &#8220;\u7d27\u6025\u4fee\u590d\u7248\u672cv1.2.1&#8221;<br>git push origin main &#8211;tags<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">4. \u5408\u5e76\u5230develop<\/h1>\n\n\n\n<p>git checkout develop<br>git merge &#8211;no-ff hotfix\/critical-bug-456<br>git branch -d hotfix\/critical-bug-456<\/p>\n\n\n\n<p class=\"has-x-large-font-size\">\u81ea\u52a8\u5316\u90e8\u7f72\u811a\u672c<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">!\/bin\/bash<\/h1>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">deploy.sh<\/h1>\n\n\n\n<p>ENVIRONMENT=$1<br>VERSION=$2<\/p>\n\n\n\n<p>case $ENVIRONMENT in<br>development)<br>echo &#8220;\ud83d\ude80 \u90e8\u7f72\u5230\u5f00\u53d1\u73af\u5883\u2026&#8221;<br>BRANCH=&#8221;develop&#8221;<br>SERVER=&#8221;dev-server.example.com&#8221;<br>DEPLOY_PATH=&#8221;\/var\/www\/dev&#8221;<br>;;<br>staging)<br>echo &#8220;\ud83d\ude80 \u90e8\u7f72\u5230\u6d4b\u8bd5\u73af\u5883\u2026&#8221;<br>BRANCH=&#8221;staging&#8221;<br>SERVER=&#8221;staging-server.example.com&#8221;<br>DEPLOY_PATH=&#8221;\/var\/www\/staging&#8221;<br>;;<br>production)<br>echo &#8220;\ud83d\ude80 \u90e8\u7f72\u5230\u751f\u4ea7\u73af\u5883\u2026&#8221;<br>BRANCH=&#8221;main&#8221;<br>SERVER=&#8221;prod-server.example.com&#8221;<br>DEPLOY_PATH=&#8221;\/var\/www\/prod&#8221;<br>;;<br>*)<br>echo &#8220;\u274c \u672a\u77e5\u73af\u5883: $ENVIRONMENT&#8221;<br>exit 1<br>;;<br>esac<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-x-large-font-size\">\u68c0\u67e5\u5f53\u524d\u5206\u652f<\/h1>\n\n\n\n<p>CURRENT_BRANCH=$(git rev-parse &#8211;abbrev-ref HEAD)<br>if [ &#8220;$CURRENT_BRANCH&#8221; != &#8220;$BRANCH&#8221; ]; then<br>echo &#8220;\u274c \u5fc5\u987b\u5728 $BRANCH \u5206\u652f\u4e0a\u90e8\u7f72\u5230 $ENVIRONMENT \u73af\u5883&#8221;<br>exit 1<br>fi<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-x-large-font-size\">\u90e8\u7f72<\/h1>\n\n\n\n<p>echo &#8220;1. \u62c9\u53d6\u6700\u65b0\u4ee3\u7801\u2026&#8221;<br>git pull origin $BRANCH<\/p>\n\n\n\n<p>echo &#8220;2. \u5b89\u88c5\u4f9d\u8d56\u2026&#8221;<br>composer install &#8211;no-dev<br>npm install &#8211;production<\/p>\n\n\n\n<p>echo &#8220;3. \u6784\u5efa\u2026&#8221;<br>npm run build<\/p>\n\n\n\n<p>echo &#8220;4. \u540c\u6b65\u5230\u670d\u52a1\u5668\u2026&#8221;<br>rsync -avz &#8211;delete \\<br>&#8211;exclude=&#8217;.git&#8217; \\<br>&#8211;exclude=&#8217;.env&#8217; \\<br>&#8211;exclude=&#8217;node_modules&#8217; \\<br>.\/ $SERVER:$DEPLOY_PATH\/<\/p>\n\n\n\n<p>echo &#8220;5. \u91cd\u542f\u670d\u52a1\u2026&#8221;<br>ssh $SERVER &#8220;cd $DEPLOY_PATH &amp;&amp; systemctl restart php-fpm &amp;&amp; systemctl restart nginx&#8221;<\/p>\n\n\n\n<p>echo &#8220;\u2705 \u90e8\u7f72\u5b8c\u6210!&#8221;<\/p>\n\n\n\n<p>\u5206\u652f\u547d\u540d\u89c4\u8303<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-x-large-font-size\">\u529f\u80fd\u5206\u652f<\/h1>\n\n\n\n<p>feature\/user-auth-123<br>feature\/payment-gateway-456<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-x-large-font-size\">\u7f3a\u9677\u4fee\u590d<\/h1>\n\n\n\n<p>bugfix\/login-error-123<br>bugfix\/api-timeout-456<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-x-large-font-size\">\u7d27\u6025\u4fee\u590d<\/h1>\n\n\n\n<p>hotfix\/security-patch-789<br>hotfix\/db-connection-999<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-x-large-font-size\">\u53d1\u5e03\u5206\u652f<\/h1>\n\n\n\n<p>release\/v1.2.0<br>release\/v2.0.0-beta<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-x-large-font-size\">\u91cd\u6784<\/h1>\n\n\n\n<p>refactor\/user-service-123<br>refactor\/database-layer-456<\/p>\n","protected":false},"excerpt":{"rendered":"<p>main (\u6216 master) &#8211; \u751f\u4ea7\u73af\u5883\u4ee3\u7801\u251c\u2500\u2500 staging &#8211; \u6d4b\u8bd5\/\u9884\u53d1 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"open","template":"","meta":{"footnotes":""},"_links":{"self":[{"href":"https:\/\/peishop.cn\/index.php\/wp-json\/wp\/v2\/pages\/2"}],"collection":[{"href":"https:\/\/peishop.cn\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/peishop.cn\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/peishop.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/peishop.cn\/index.php\/wp-json\/wp\/v2\/comments?post=2"}],"version-history":[{"count":2,"href":"https:\/\/peishop.cn\/index.php\/wp-json\/wp\/v2\/pages\/2\/revisions"}],"predecessor-version":[{"id":12,"href":"https:\/\/peishop.cn\/index.php\/wp-json\/wp\/v2\/pages\/2\/revisions\/12"}],"wp:attachment":[{"href":"https:\/\/peishop.cn\/index.php\/wp-json\/wp\/v2\/media?parent=2"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}