{"id":39,"date":"2021-12-04T15:16:49","date_gmt":"2021-12-04T07:16:49","guid":{"rendered":"http:\/\/pkant.com\/?p=39"},"modified":"2023-12-01T14:14:25","modified_gmt":"2023-12-01T06:14:25","slug":"sourcetree-git-%e5%af%bc%e5%87%ba%e9%80%89%e4%b8%ad%e6%96%87%e4%bb%b6sh%e8%84%9a%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/jwever.cn\/index.php\/2021\/12\/04\/sourcetree-git-%e5%af%bc%e5%87%ba%e9%80%89%e4%b8%ad%e6%96%87%e4%bb%b6sh%e8%84%9a%e6%9c%ac\/","title":{"rendered":"Sourcetree + git \u5bfc\u51fa\u9009\u4e2d\u6587\u4ef6sh\u811a\u672c"},"content":{"rendered":"<h1>\u65b0\u5efa\u6587\u4ef6<code>export.sh<\/code>,\u590d\u5236\u5185\u5bb9\uff0c\u4fee\u6539\u5bfc\u51fa\u6587\u4ef6\u5939\u4e3a\u4f60\u7684\u4fdd\u5b58\u8def\u5f84<\/h1>\n<pre class=\"prettyprint linenums\" ><code class=\"language-bash\">#!\/bin\/bash\nDATE=`date +%m%d`\nINIT_PATH=${1%\/}\nFILE_PATH=${2%\/}\n#\u81ea\u5b9a\u4e49\u4fdd\u5b58\u7684\u4f4d\u7f6e\nBASE_PATH=&quot;\u5bfc\u51fa\u4fdd\u5b58\u6587\u4ef6\u5939\/$DATE&quot;\nSAVE_PATH=&quot;&quot;\nfunction checksavepath() {\n    #\u5e8f\u53f7\uff0c\u4fdd\u8bc1\u6bcf\u6b21\u90fd\u662f\u65b0\u521b\u5efa\u7684\u201c\u65e5\u671f-[index]\u201d\u7684\u6587\u4ef6\u5939\n    index=1\n    path=${BASE_PATH}&quot;-&quot;$index\n    while [ -d $path ]\n    do\n        let &quot;index+=1&quot;\n        path=${BASE_PATH}&quot;-&quot;$index\n    done\n    SAVE_PATH=$path\n#   echo &quot;save path: ${SAVE_PATH}&quot;\n    mkdir -p ${SAVE_PATH}\n#    touch $SAVE_PATH&quot;.log&quot;\n}\nfunction getfilefromdir(){\n    for file in ` ls $1`\n    do\n        if [ -d $1&quot;\/&quot;$file ]\n        then\n            #echo ${SAVE_PATH}&quot;\/&quot;$file\n            mkdir ${SAVE_PATH}&quot;\/&quot;$file\n            getfilefromdir $1&quot;\/&quot;$file ${SAVE_PATH}&quot;\/&quot;$file\n        else\n            local path=&quot;$1&quot;\n            local name=$file\n            if [ ! -f $SAVE_PATH&quot;\/&quot;$name ]\n            then\n                #\u786e\u8ba4\u76ee\u5f55\u5b58\u5728\uff0c\u8def\u5f84\u4e0d\u5b58\u5728\u5219\u521b\u5efa\n                parent=$(dirname $name)\n                #\u5e94\u8be5\u8865\u5168\u7684\u6587\u4ef6\u5939\u8def\u5f84\n                dirs=&quot;${parent#${INIT_PATH}}&quot;\n                dirs=&quot;${dirs:${#FILE_PATH}}&quot;\n                #\u6587\u4ef6\u540d\n                filename=&quot;${var##*\/}&quot;;\n                #\u8865\u5168\u6587\u4ef6\u5939\n                mkdir -p $2$dirs\n                #\u8f93\u51fa\u8bed\u53e5\n                echo &quot;cp ${path} to $2${dirs}\/${filename}&quot;\n                #\u590d\u5236\u6587\u4ef6\n                cp ${path} &quot;$2${dirs}\/${filename}&quot;\n            else\n                echo &quot;${path} file already exists&quot;\n            #echo &quot;${path}&quot; &gt;&gt; $SAVE_PATH&quot;.log&quot; 2&gt;&amp;1\n            fi\n        fi\n    done\n}\nchecksavepath\n#\u904d\u5386\u6240\u6709\u53c2\u6570\nfor arg in $*\ndo\n#\u5224\u65ad\u5e76\u6392\u9664\u4e3a\u9879\u76ee\u8def\u5f84\u7684\u53c2\u6570\nif [ $arg != $FILE_PATH ]\nthen\n    #\u590d\u5236\u6587\u4ef6\n    getfilefromdir ${FILE_PATH}&quot;\/&quot;$arg $SAVE_PATH\nfi\ndone<\/code><\/pre>\n<h1>\u65b0\u5efa\u6587\u4ef6<code>export.bat<\/code>\uff0c\u52a0\u5165\u4ee5\u4e0b\u5185\u5bb9\uff0c\u4fee\u6539<code>D:\\Program Files\\Git\\bin\\sh.exe<\/code> \u4e3a<code>\u4f60\u7684git\u5b89\u88c5\u76ee\u5f55 \/bin\/sh.exe<\/code>\uff1b\u4fee\u6539<code>D:\\phpstudy_pro\\export.sh<\/code>\u4e3a\u4e0a\u4e00\u6b65 <code>export.sh<\/code> \u8def\u5f84<\/h1>\n<pre class=\"prettyprint linenums\" ><code class=\"language-php\">@echo off\n&quot;D:\\Program Files\\Git\\bin\\sh.exe&quot; D:\\phpstudy_pro\\export.sh %USERPROFILE%\\Desktop %*<\/code><\/pre>\n<h1>sourcetree \u5de5\u5177&gt;\u9009\u9879&gt;\u81ea\u5b9a\u4e49\u64cd\u4f5c \u6309\u5982\u4e0b\u914d\u7f6e<\/h1>\n<p><img data-original=\"http:\/\/jwever.cn\/wp-content\/uploads\/2021\/12\/2021122508091572.png\"  alt=\"\" \/><\/p>\n<noscript><img decoding=\"async\" src=\"http:\/\/jwever.cn\/wp-content\/uploads\/2021\/12\/2021122508091572.png\" alt=\"\" \/><\/p><\/noscript>\n","protected":false},"excerpt":{"rendered":"<p>\u65b0\u5efa\u6587\u4ef6export.sh,\u590d\u5236\u5185\u5bb9\uff0c\u4fee\u6539\u5bfc\u51fa\u6587\u4ef6\u5939\u4e3a\u4f60\u7684\u4fdd\u5b58\u8def\u5f84 #!\/bin\/bash DATE=`dat [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[10,12,11],"class_list":["post-39","post","type-post","status-publish","format-standard","hentry","category-houduan","tag-git","tag-sourcetree"],"_links":{"self":[{"href":"https:\/\/jwever.cn\/index.php\/wp-json\/wp\/v2\/posts\/39","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jwever.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jwever.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jwever.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jwever.cn\/index.php\/wp-json\/wp\/v2\/comments?post=39"}],"version-history":[{"count":4,"href":"https:\/\/jwever.cn\/index.php\/wp-json\/wp\/v2\/posts\/39\/revisions"}],"predecessor-version":[{"id":74,"href":"https:\/\/jwever.cn\/index.php\/wp-json\/wp\/v2\/posts\/39\/revisions\/74"}],"wp:attachment":[{"href":"https:\/\/jwever.cn\/index.php\/wp-json\/wp\/v2\/media?parent=39"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jwever.cn\/index.php\/wp-json\/wp\/v2\/categories?post=39"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jwever.cn\/index.php\/wp-json\/wp\/v2\/tags?post=39"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}