{"id":103,"date":"2022-05-06T00:48:21","date_gmt":"2022-05-05T16:48:21","guid":{"rendered":"https:\/\/www.bywwh.com\/?p=103"},"modified":"2022-06-04T10:40:15","modified_gmt":"2022-06-04T02:40:15","slug":"git_tool","status":"publish","type":"post","link":"https:\/\/www.bywwh.com\/index.php\/2022\/05\/06\/git_tool\/","title":{"rendered":"Github\u4e0a\u4f20\u4ee3\u7801\u5de5\u5177"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p>\u622a\u56fe\u5c55\u793a\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"490\" height=\"313\" src=\"https:\/\/www.bywwh.com\/wp-content\/uploads\/2022\/05\/\u5c4f\u5e55\u5feb\u7167-2022-05-06-00.39.29.png\" alt=\"\" class=\"wp-image-104\" srcset=\"https:\/\/www.bywwh.com\/wp-content\/uploads\/2022\/05\/\u5c4f\u5e55\u5feb\u7167-2022-05-06-00.39.29.png 490w, https:\/\/www.bywwh.com\/wp-content\/uploads\/2022\/05\/\u5c4f\u5e55\u5feb\u7167-2022-05-06-00.39.29-300x192.png 300w\" sizes=\"auto, (max-width: 490px) 100vw, 490px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"631\" height=\"357\" src=\"https:\/\/www.bywwh.com\/wp-content\/uploads\/2022\/05\/\u5c4f\u5e55\u5feb\u7167-2022-05-06-00.43.02.png\" alt=\"\" class=\"wp-image-106\" srcset=\"https:\/\/www.bywwh.com\/wp-content\/uploads\/2022\/05\/\u5c4f\u5e55\u5feb\u7167-2022-05-06-00.43.02.png 631w, https:\/\/www.bywwh.com\/wp-content\/uploads\/2022\/05\/\u5c4f\u5e55\u5feb\u7167-2022-05-06-00.43.02-300x170.png 300w, https:\/\/www.bywwh.com\/wp-content\/uploads\/2022\/05\/\u5c4f\u5e55\u5feb\u7167-2022-05-06-00.43.02-520x293.png 520w\" sizes=\"auto, (max-width: 631px) 100vw, 631px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Shell\u4ee3\u7801\u5c55\u793a\uff1a<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>#!\/bin\/bash\n\n#\u5b9a\u4e49\u5b57\u4f53\u989c\u8272\n#\u7eff\u8272\ngreen() {\nif [ &quot;$1&quot; == &quot;read&quot; ];then\n      color= echo -e &quot;\\033[32m$2\\033[0m&quot;\n      read -r -p &quot;$color&quot; myStr\nelif [ &quot;$1&quot; == &quot;txt&quot; ];then\n      echo -e &quot;\\033[32m$2\\033[0m&quot;\nelif [ &quot;$1&quot; == &quot;key&quot; ];then\n      echo -e &quot;\\033[32m$2\\033[0m&quot; \n      read -r -p &quot;$color&quot; key\nelif [ &quot;$1&quot; == &quot;repo&quot; ];then\n      echo -e &quot;\\033[32m$2\\033[0m&quot; \n      read -r -p &quot;$color&quot; repo      \nfi\n\n}\n\n#\u9ec4\u8272\nyellow() {\nif [ &quot;$1&quot; == &quot;txt&quot; ];then\n      echo -e &quot;\\033[33m$2\\033[0m&quot;\nfi\n\n}\n\ntitle() {\ngreen txt &quot;-------------------------&quot;\ngreen txt &quot;-     Github\u4e0a\u4f20\u4ee3\u7801    -&quot;\ngreen txt &quot;-         bywwh         -&quot;\ngreen txt &quot;-------------------------&quot;\n\n}\n\ncompack1() {\n#\u8bbe\u7f6e\u7528\u6237\u540d\u548c\u90ae\u7bb1\ngreen read &quot;\u8bf7\u8f93\u5165\u90ae\u7bb1(Email)\uff1a&quot;\necho\nyellow txt &quot;$myStr&quot;\ngit config --global user.email &quot;$myStr&quot;\ngreen read &quot;\u8bf7\u8f93\u5165\u7528\u6237\u540d(Username)\uff1a&quot;\necho\nyellow txt &quot;$myStr&quot;   \ngit config --global user.name &quot;$myStr&quot;\n\n#\u8bbe\u7f6e\u5bc6\u94a5\ngreen key &quot;\u8bf7\u8f93\u5165Github\u5bc6\u94a5(Personal access tokens)\uff1a&quot;\necho\nyellow txt &quot;$key&quot;\ngreen repo &quot;\u8bf7\u8f93\u5165\u4ed3\u5e93\u540d(Project)\uff1a&quot;\necho\nyellow txt &quot;$repo&quot;\ngit remote set-url origin https:\/\/&quot;$key&quot;@github.com\/&quot;$myStr&quot;\/&quot;$repo&quot;\ngreen txt &quot;\u8bbe\u7f6e\u5b8c\u6bd5\uff01&quot;\necho\ntouch done.log\ncat&gt; done.log &lt;&lt;END\nKey setting succeeded!\nEND\n\n}\n\ncompack2() {\n#\u4e0a\u4f20\u4ee3\u7801\ngit add -A\ngreen read &quot;\u8bf7\u8f93\u5165\u63d0\u4ea4\u8bb0\u5f55(Git commit)\uff1a&quot;\necho\nyellow txt &quot;$myStr&quot;\ngit commit -m &quot;$myStr&quot;\ngreen read &quot;\u8bf7\u8f93\u5165\u4ed3\u5e93\u5206\u652f(Branch)\uff1a&quot;\necho\nyellow txt &quot;$myStr&quot;\ngit push origin &quot;$myStr&quot;\n\n}\n\n#\u5224\u65ad\u662f\u5426\u5df2\u8bbe\u7f6e\u5bc6\u94a5\nif [ -e done.log ]; then\n      title\n      compack2\nelse\n      title\n      compack1\n      compack2\nfi\n<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u622a\u56fe\u5c55\u793a\uff1a Shell\u4ee3\u7801\u5c55\u793a\uff1a<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[16],"class_list":["post-103","post","type-post","status-publish","format-standard","hentry","category-linux","tag-github"],"_links":{"self":[{"href":"https:\/\/www.bywwh.com\/index.php\/wp-json\/wp\/v2\/posts\/103","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bywwh.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bywwh.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bywwh.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bywwh.com\/index.php\/wp-json\/wp\/v2\/comments?post=103"}],"version-history":[{"count":6,"href":"https:\/\/www.bywwh.com\/index.php\/wp-json\/wp\/v2\/posts\/103\/revisions"}],"predecessor-version":[{"id":126,"href":"https:\/\/www.bywwh.com\/index.php\/wp-json\/wp\/v2\/posts\/103\/revisions\/126"}],"wp:attachment":[{"href":"https:\/\/www.bywwh.com\/index.php\/wp-json\/wp\/v2\/media?parent=103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bywwh.com\/index.php\/wp-json\/wp\/v2\/categories?post=103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bywwh.com\/index.php\/wp-json\/wp\/v2\/tags?post=103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}