{"id":2566,"date":"2024-05-09T16:10:02","date_gmt":"2024-05-09T07:10:02","guid":{"rendered":"https:\/\/weblog.hirohiro716.com\/?p=2566"},"modified":"2024-05-10T11:56:35","modified_gmt":"2024-05-10T02:56:35","slug":"git%e3%81%ae%e7%b0%a1%e5%8d%98%e3%81%aa%e4%bd%bf%e3%81%84%e6%96%b9","status":"publish","type":"post","link":"https:\/\/weblog.hirohiro716.com\/?p=2566","title":{"rendered":"Git\u306e\u7c21\u5358\u306a\u4f7f\u3044\u65b9"},"content":{"rendered":"<p>\n\u300cgit clone\u300d\u3057\u3066\u304b\u3089\u958b\u767a\u3059\u308b\u4e0a\u3067\u3001\u56f0\u3089\u306a\u3044\u3088\u3046\u306b\u3059\u308b\u305f\u3081\u306e\u6700\u4f4e\u9650\u306e\u5099\u5fd8\u9332\u3067\u3059\u3002\n<\/p>\n<pre class=\"brush: plain; title: \u74b0\u5883; notranslate\" title=\"\u74b0\u5883\">\r\nDebian 12.5\r\nGit 2.39.2\r\n<\/pre>\n<h4>\u8a2d\u5b9a<\/h4>\n<p>\n\u30e6\u30fc\u30b6\u30fc\u540d\u3068E-mail\u30a2\u30c9\u30ec\u30b9\u3092\u8a2d\u5b9a\u3059\u308b\u3002<br \/>\n\u8a2d\u5b9a\u306f~\/.gitconfig\u306b\u4fdd\u5b58\u3055\u308c\u308b\u3002<code>--global<\/code>\u3092\u4ed8\u3051\u306a\u3044\u5834\u5408\u306f\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u30ed\u30fc\u30ab\u30eb\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306b\u4fdd\u5b58\u3055\u308c\u308b\u3002\n<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ git config --global user.name &quot;username&quot;\r\n$ git config --global user.email &quot;user@hirohiro716.com&quot;\r\n<\/pre>\n<p>\n\u8a8d\u8a3c\u60c5\u5831\u3092\u5e73\u6587\u3067\u8a18\u61b6\u3055\u305b\u308b\u3002<br \/>\n<code>--global<\/code>\u3092\u4ed8\u3051\u306a\u3044\u5834\u5408\u3001credential.helper\u3068\u3044\u3046\u8a2d\u5b9a\u5024\u306e\u307f\u304c\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u30ed\u30fc\u30ab\u30eb\u8a2d\u5b9a\u306b\u4fdd\u5b58\u3055\u308c\u3001\u8a8d\u8a3c\u60c5\u5831\u306f~\/.git-credentials\u306b\u5e73\u6587\u3067\u4fdd\u5b58\u3055\u308c\u308b\u3002\n<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ git config --global credential.helper store\r\n<\/pre>\n<h4>\u57fa\u672c\u7684\u306a\u64cd\u4f5c<\/h4>\n<p>\n\u30ef\u30fc\u30af\u30c4\u30ea\u30fc\u306e\u72b6\u614b\u3092\u78ba\u8a8d\u3059\u308b\u3002\n<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ git status\r\n<\/pre>\n<p>\n\u30ea\u30e2\u30fc\u30c8\u3082\u542b\u3081\u3066\u30d6\u30e9\u30f3\u30c1\u4e00\u89a7\u3092\u8868\u793a\u3059\u308b\u3002<br \/>\n\u203b-a\u306b\u7701\u7565\u53ef\u80fd\n<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ git branch --all\r\n<\/pre>\n<p>\n\u30ea\u30e2\u30fc\u30c8\u306e\u5225\u306e\u30d6\u30e9\u30f3\u30c1\u306b\u5909\u66f4\u3059\u308b\u3002\n<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ git switch branch2\r\n<\/pre>\n<p>\n\u30ed\u30fc\u30ab\u30eb\u306b\u73fe\u5728\u306e\u30d6\u30e9\u30f3\u30c1\u306e\u6d3e\u751f\u30d6\u30e9\u30f3\u30c1\u3092\u4f5c\u6210\u3059\u308b\u3002\n<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ git branch branch3\r\n<\/pre>\n<p>\n\u4f5c\u6210\u3057\u305f\u30ed\u30fc\u30ab\u30eb\u306e\u30d6\u30e9\u30f3\u30c1\u306b\u5207\u308a\u66ff\u3048\u308b\u3002\n<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ git checkout branch3\r\n<\/pre>\n<p>\n\u4f5c\u6210\u3057\u305f\u30ed\u30fc\u30ab\u30eb\u306e\u30d6\u30e9\u30f3\u30c1\u3092\u30ea\u30e2\u30fc\u30c8\u306bpush\u3059\u308b\u3002<br \/>\n\u203b-u\u306b\u7701\u7565\u53ef\u80fd\n<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ git push --set-upstream origin branch3\r\n<\/pre>\n<h4>\u30b3\u30df\u30c3\u30c8\u95a2\u9023\u306e\u64cd\u4f5c<\/h4>\n<p>\n\u5909\u66f4\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u30b9\u30c6\u30fc\u30b8\u30f3\u30b0\u30a8\u30ea\u30a2\u306b\u8ffd\u52a0\u3059\u308b\u3002\n<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ git add test.txt\r\n<\/pre>\n<p>\n\u5909\u66f4\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u3059\u3079\u3066\u30b9\u30c6\u30fc\u30b8\u30f3\u30b0\u30a8\u30ea\u30a2\u306b\u8ffd\u52a0\u3059\u308b\u3002\n<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ git add .\r\n<\/pre>\n<p>\ncommit\u3092\u4f5c\u6210\u3059\u308b\u3002<br \/>\n\u203b-m\u306b\u7701\u7565\u53ef\u80fd\n<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ git commit --message &quot;Commit message&quot;\r\n<\/pre>\n<p>\n\u4f5c\u6210\u3057\u305fcommit\u3092\u30ea\u30e2\u30fc\u30c8\u306bpush\u3059\u308b\u3002\n<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ git push\r\n<\/pre>\n<p>\ncommit\u306e\u30ed\u30b0\u3092\u8868\u793a\u3059\u308b\u3002\n<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ git log\r\n<\/pre>\n<p>\n\u7279\u5b9a\u30d5\u30a1\u30a4\u30eb\u306ecommit\u306e\u30ed\u30b0\u3092\u8868\u793a\u3059\u308b\u3002\n<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ git log *.txt\r\n<\/pre>\n<h4>\u7279\u5b9a\u306e\u30b3\u30df\u30c3\u30c8\u3092\u53d6\u308a\u6d88\u3059\u30b3\u30df\u30c3\u30c8\u3092\u4f5c\u6210<\/h4>\n<p>\n\u53d6\u308a\u6d88\u3059\u5bfe\u8c61commit\u3092\u6307\u5b9a\u3059\u308b\u3002\u8907\u6570\u4eba\u3067\u958b\u767a\u3057\u3066\u3044\u308b\u5834\u5408\u3084\u3001\u5c65\u6b74\u3092\u6b8b\u3057\u305f\u3044\u5834\u5408\u306f\u3053\u3061\u3089\u3092\u4f7f\u7528\u3059\u308b\u3002\n<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ git revert HEAD\r\n$ git push\r\n<\/pre>\n<h4>HEAD\u3092\u524d\u306e\u72b6\u614b\u306b\u623b\u3057\u3066\u5c65\u6b74\u304b\u3089\u3082\u524a\u9664<\/h4>\n<p>\n\u623b\u3057\u305f\u3044\u72b6\u614b(commit)\u3092\u6307\u5b9a\u3059\u308b\u3002\u3059\u3079\u3066\u306a\u304b\u3063\u305f\u3053\u3068\u306b\u306a\u308b\u306e\u3067\u3001\u500b\u4eba\u958b\u767a\u3067\u8aa4\u3063\u3066push\u3057\u305f\u5834\u5408\u306f\u3053\u3061\u3089\u3092\u4f7f\u7528\u3059\u308b\u5834\u9762\u304c\u591a\u3044\u3002<br \/>\n\u203bHEAD^\u306fHEAD\u306e1\u3064\u524d\u306ecommit\u3092\u6307\u3059<br \/>\n\u203b<code>--soft<\/code>\u3067\u5909\u66f4\u30d5\u30a1\u30a4\u30eb\u3092\u30b9\u30c6\u30fc\u30b8\u30f3\u30b0\u30a8\u30ea\u30a2\u306b\u6b8b\u3059<br \/>\n\u203b<code>--mixed<\/code>\u3067\u5909\u66f4\u30d5\u30a1\u30a4\u30eb\u3092\u30b9\u30c6\u30fc\u30b8\u30f3\u30b0\u30a8\u30ea\u30a2\u304b\u3089\u53d6\u308a\u9664\u3044\u3066\u6b8b\u3059<br \/>\n\u203b<code>--hard<\/code>\u3067\u3059\u3079\u3066\u306e\u5909\u66f4\u3092\u7834\u68c4\u3057\u3066HEAD^\u306e\u72b6\u614b\u306b\u623b\u3059\n<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ git reset --mixed HEAD^\r\n$ git push --force\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u300cgit clone\u300d\u3057\u3066\u304b\u3089\u958b\u767a\u3059\u308b\u4e0a\u3067\u3001\u56f0\u3089\u306a\u3044\u3088\u3046\u306b\u3059\u308b\u305f\u3081\u306e\u6700\u4f4e\u9650\u306e\u5099\u5fd8\u9332\u3067\u3059\u3002 Debian 12.5 Git 2.39.2 \u8a2d\u5b9a \u30e6\u30fc\u30b6\u30fc\u540d\u3068E-mail\u30a2\u30c9\u30ec\u30b9\u3092\u8a2d\u5b9a\u3059\u308b\u3002 \u8a2d\u5b9a\u306f~\/.gitconfig\u306b [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[],"class_list":["post-2566","post","type-post","status-publish","format-standard","hentry","category-git"],"views":887,"_links":{"self":[{"href":"https:\/\/weblog.hirohiro716.com\/index.php?rest_route=\/wp\/v2\/posts\/2566","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/weblog.hirohiro716.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/weblog.hirohiro716.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/weblog.hirohiro716.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/weblog.hirohiro716.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2566"}],"version-history":[{"count":32,"href":"https:\/\/weblog.hirohiro716.com\/index.php?rest_route=\/wp\/v2\/posts\/2566\/revisions"}],"predecessor-version":[{"id":2600,"href":"https:\/\/weblog.hirohiro716.com\/index.php?rest_route=\/wp\/v2\/posts\/2566\/revisions\/2600"}],"wp:attachment":[{"href":"https:\/\/weblog.hirohiro716.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2566"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/weblog.hirohiro716.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2566"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/weblog.hirohiro716.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2566"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}