{"id":37233,"date":"2023-01-22T23:17:25","date_gmt":"2023-05-04T15:35:01","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/git%e5%91%bd%e4%bb%a4-3\/"},"modified":"2024-04-29T10:58:28","modified_gmt":"2024-04-29T02:58:28","slug":"git%e5%91%bd%e4%bb%a4-3","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/git%e5%91%bd%e4%bb%a4-3\/","title":{"rendered":"Git\u547d\u4ee4"},"content":{"rendered":"<h2>Git\u7684\u57fa\u7840\u77e5\u8bc6<\/h2>\n<p>\u4f5c\u696d\u76ee\u5f55\u6216\u5de5\u4f5c\u533a &#8211; \u5728\u8fdb\u884c\u5b9e\u9645\u64cd\u4f5c\u7684\u76ee\u5f55<br \/>\n\u2191 \u6dfb\u52a0 \u2191<br \/>\n\u2191 \u6682\u5b58\u533a\u6216\u7d22\u5f15<br \/>\n\u2191 \u5b58\u5728\u63d0\u4ea4\u7684\u6587\u4ef6\u7684\u865a\u62df\u4f4d\u7f6e<br \/>\n\u2191 \u63d0\u4ea4 \u2191<br \/>\n\u2191 \u672c\u5730\u4ed3\u5e93<br \/>\n\u2191 \u7528\u4e8e\u5728\u81ea\u8eab\u7684\u5de5\u4f5c\u73af\u5883\u4e2d\u8fdb\u884c\u7248\u672c\u7ba1\u7406\u800c\u521b\u5efa\u7684\u4ed3\u5e93<br \/>\n\u2191 \u62c9\u53d6 \u63a8\u9001 \u2191<br \/>\n\u8fdc\u7a0b\u4ed3\u5e93<br \/>\n\u4e3a\u4e86\u591a\u4eba\u7248\u672c\u7ba1\u7406\u548c\u5171\u4eab\u800c\u653e\u7f6e\u5728\u4e13\u7528\u670d\u52a1\u5668\u4e0a\u7684\u4ed3\u5e93<\/p>\n<p>\u4ed3\u5e93 &#8211; \u8bb0\u5f55\u6587\u4ef6\u548c\u76ee\u5f55\u72b6\u6001\u7684\u5730\u65b9\u3002<\/p>\n<h2>\u6dfb\u52a0<\/h2>\n<p>\u5c06\u6587\u4ef6\u6dfb\u52a0\u5230\u6682\u5b58\u533a\u3002<\/p>\n<pre class=\"post-pre\"><code>git add \u3010\u30d5\u30a1\u30a4\u30eb\u540d\u3011\r\n\r\n<span class=\"c\"># \u5909\u66f4\u3055\u308c\u305f\u5168\u30d5\u30a1\u30a4\u30eb\u3092\u30b9\u30c6\u30fc\u30b8\u30f3\u30b0\u30fb\u30a8\u30ea\u30a2\u306b\u8ffd\u52a0<\/span>\r\ngit add <span class=\"nt\">-A<\/span>\r\ngit add <span class=\"nt\">--all<\/span>\r\n\r\n<span class=\"c\"># \u30ab\u30ec\u30f3\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u4ee5\u4e0b\u306e\u3001\u5909\u66f4\u3055\u308c\u305f\u5168\u30d5\u30a1\u30a4\u30eb\u3092\u30b9\u30c6\u30fc\u30b8\u30f3\u30b0\u30fb\u30a8\u30ea\u30a2\u306b\u8ffd\u52a0<\/span>\r\ngit add <span class=\"nb\">.<\/span>\r\n\r\n<span class=\"c\"># \u30d0\u30fc\u30b8\u30e7\u30f3\u7ba1\u7406\u3055\u308c\u3066\u304a\u308a\u3001\u5909\u66f4\u3055\u308c\u305f\u5168\u30d5\u30a1\u30a4\u30eb\u3092\u30b9\u30c6\u30fc\u30b8\u30f3\u30b0\u30fb\u30a8\u30ea\u30a2\u306b\u8ffd\u52a0<\/span>\r\ngit add <span class=\"nt\">-u<\/span>\r\ngit add <span class=\"nt\">--update<\/span>\r\n<\/code><\/pre>\n<div>\n<div class=\"post-table\">\nNew FilesModified FilesDeleted Filesgit add -A\u3007\u3007\u3007git add .\u3007\u3007\u3007git add -u\u00d7\u3007\u3007<\/div>\n<\/div>\n<p>\u3010\u53c2\u8003\u3011<br \/>\ngit add -u \u3001git add -A\u3001\u4ee5\u53cagit add . \u7684\u533a\u522b\u662f\u4ec0\u4e48\uff1f<\/p>\n<h2>\u5206\u884c<\/h2>\n<p>\u5217\u51fa\u672c\u5730\u5b58\u50a8\u5e93\u5206\u652f\u5217\u8868<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span>git branch\r\n<span class=\"k\">*<\/span> primary\r\n<span class=\"c\"># \u73fe\u5728\u3001\u81ea\u5206\u304c\u4f5c\u696d\u3057\u3066\u3044\u308b\u30d6\u30e9\u30f3\u30c1\u306e\u5148\u982d\u306b * \u304c\u4ed8\u304f<\/span>\r\n<\/code><\/pre>\n<p>\u5728\u672c\u5730\u5b58\u50a8\u5e93\u4e2d\u521b\u5efa\u4e00\u4e2a\u5206\u652f\u3002<\/p>\n<pre class=\"post-pre\"><code>git branch \u3010\u30d6\u30e9\u30f3\u30c1\u540d\u3011\r\n\r\n<span class=\"c\"># ex. \u30ed\u30fc\u30ab\u30eb\u30ea\u30dd\u30b8\u30c8\u30ea\u306b secondary \u3068\u3044\u3046\u30d6\u30e9\u30f3\u30c1\u3092\u4f5c\u6210<\/span>\r\n<span class=\"nv\">$ <\/span>git branch secondary\r\n<span class=\"nv\">$ <\/span>git branch\r\n<span class=\"k\">*<\/span> primary\r\n  secondary\r\n<\/code><\/pre>\n<p>\u5220\u9664\u672c\u5730\u5b58\u50a8\u5e93\u7684\u5206\u652f<\/p>\n<pre class=\"post-pre\"><code>git branch <span class=\"nt\">-d<\/span> \u3010\u30d6\u30e9\u30f3\u30c1\u540d\u3011\r\ngit branch <span class=\"nt\">--delete<\/span> \u3010\u30d6\u30e9\u30f3\u30c1\u540d\u3011\r\n\r\n<span class=\"c\"># ex. secondary \u3068\u3044\u3046\u30ed\u30fc\u30ab\u30eb\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u30d6\u30e9\u30f3\u30c1\u3092\u524a\u9664<\/span>\r\n<span class=\"nv\">$ <\/span>git branch <span class=\"nt\">-d<\/span> secondary\r\nDeleted branch secondary <span class=\"o\">(<\/span>was 0000000<span class=\"o\">)<\/span><span class=\"nb\">.<\/span>\r\n<\/code><\/pre>\n<p>\u3010\u53c2\u8003\u3011<br \/>\nGit &#8211; \u5206\u652f\u662f\u4ec0\u4e48<br \/>\n\u7334\u5b50\u8001\u5e08\u7684Git\u5165\u95e8\u6559\u7a0b &#8211; \u5206\u652f\u662f\u4ec0\u4e48<\/p>\n<h2>\u7ed3\u8d26<\/h2>\n<p>\u5207\u6362\u672c\u5730\u4ed3\u5e93\u7684\u5206\u652f<\/p>\n<pre class=\"post-pre\"><code>git checkout \u3010\u5207\u308a\u66ff\u3048\u308b\u30d6\u30e9\u30f3\u30c1\u540d\u3011\r\n\r\n<span class=\"c\"># ex. \u30d6\u30e9\u30f3\u30c1\u3092 primary \u304b\u3089 secondary \u3078\u5207\u308a\u66ff\u3048\u308b<\/span>\r\n<span class=\"nv\">$ <\/span>git checkout secondary\r\nSwitched to branch <span class=\"s1\">'secondary'<\/span>\r\n<span class=\"nv\">$ <\/span>git branch\r\n  primary\r\n<span class=\"k\">*<\/span> secondary\r\n<span class=\"c\"># \u73fe\u5728\u3001\u81ea\u5206\u304c\u4f5c\u696d\u3057\u3066\u3044\u308b\u30d6\u30e9\u30f3\u30c1\u306e\u5148\u982d\u306b * \u304c\u4ed8\u304f<\/span>\r\n<\/code><\/pre>\n<p>\u5728\u672c\u5730\u4ed3\u5e93\u4e0a\u521b\u5efa\u4e00\u4e2a\u5206\u652f\uff0c\u5e76\u5207\u6362\u5230\u65b0\u7684\u5206\u652f\u4e0a\u3002<\/p>\n<pre class=\"post-pre\"><code>git checkout <span class=\"nt\">-b<\/span> \u3010\u30d6\u30e9\u30f3\u30c1\u540d\u3011\r\n\r\n<span class=\"c\"># ex. \u30ed\u30fc\u30ab\u30eb\u30ea\u30dd\u30b8\u30c8\u30ea\u306b secondary \u3068\u3044\u3046\u30d6\u30e9\u30f3\u30c1\u3092\u4f5c\u6210\u3057\u3001secondary \u3078\u5207\u308a\u66ff\u3048\u308b<\/span>\r\n<span class=\"nv\">$ <\/span>git checkout <span class=\"nt\">-b<\/span> secondary\r\nSwitched to a new branch <span class=\"s1\">'secondary'<\/span>\r\n<span class=\"nv\">$ <\/span>git branch\r\n  primary\r\n<span class=\"k\">*<\/span> secondary\r\n<\/code><\/pre>\n<h2>\u590d\u5236<\/h2>\n<p>\u590d\u5236\u5b58\u50a8\u5e93<\/p>\n<pre class=\"post-pre\"><code>git clone \u3010\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u5834\u6240\uff08URL\uff09\u3011 \u3010\u30ea\u30dd\u30b8\u30c8\u30ea\u3092\u8907\u88fd\u3059\u308b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3011\r\n\r\n<span class=\"c\"># ex. \u30ab\u30ec\u30f3\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b https:\/\/remote.repos\/itory \u3068\u3044\u3046\u30ea\u30e2\u30fc\u30c8\u30ea\u30dd\u30b8\u30c8\u30ea\u3092\u8907\u88fd<\/span>\r\n<span class=\"nv\">$ <\/span>git clone https:\/\/remote.repos\/itory\r\n\r\n<span class=\"c\"># ex. \/home\/git \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b https:\/\/remote.repos\/itory \u3068\u3044\u3046\u30ea\u30e2\u30fc\u30c8\u30ea\u30dd\u30b8\u30c8\u30ea\u3092\u8907\u88fd<\/span>\r\n<span class=\"nv\">$ <\/span>git clone https:\/\/remote.repos\/itory \/home\/git\r\n<\/code><\/pre>\n<h2>\u6295\u5165<\/h2>\n<p>\u5c06\u821e\u53f0\u533a\u57df\u7684\u72b6\u6001\u8bb0\u5f55\u5230\u4ee3\u7801\u5e93\u4e2d\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"c\"># \u30b3\u30df\u30c3\u30c8\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u6307\u5b9a<\/span>\r\ngit commit <span class=\"nt\">-m<\/span> <span class=\"s2\">\"\u3010\u30e1\u30c3\u30bb\u30fc\u30b8\u3011\"<\/span>\r\ngit commit <span class=\"nt\">--message<\/span><span class=\"o\">=<\/span><span class=\"s2\">\"\u3010\u30e1\u30c3\u30bb\u30fc\u30b8\u3011\"<\/span>\r\n\r\n<span class=\"c\"># \u76f4\u524d\u306e\u30b3\u30df\u30c3\u30c8\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u4fee\u6b63\u3057\u3001\u5c65\u6b74\u3092\u4e0a\u66f8\u304d<\/span>\r\ngit commit <span class=\"nt\">--amend<\/span>\r\n\r\n<span class=\"c\"># \u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u6307\u5b9a\u3057\u306a\u3044\u30b3\u30df\u30c3\u30c8\u3092\u8a31\u53ef<\/span>\r\ngit commit <span class=\"nt\">-m<\/span> <span class=\"nt\">--allow-empty-message<\/span>\r\n<\/code><\/pre>\n<p>\u5c06\u6dfb\u52a0\u5230\u6682\u5b58\u533a\u7684style.css\u6587\u4ef6\u8bb0\u5f55\u5230\u4ee3\u7801\u4ed3\u5e93\u4e2d\u3002<\/p>\n<pre class=\"post-pre\"><code>$ git commit -m \"style.css added\"\r\n[primary 9999999] style.css added\r\n 1 file changed, 0 insertions(+), 0 deletions(-)\r\n create mode 100644 style.css\r\n<\/code><\/pre>\n<h2>\u914d\u7f6e<\/h2>\n<p>\u7f16\u8f91\u548c\u786e\u8ba4\u8bbe\u5b9a\u5185\u5bb9<\/p>\n<pre class=\"post-pre\"><code><span class=\"c\"># \u30e6\u30fc\u30b6\u8b58\u5225\u60c5\u5831\uff08\u30e6\u30fc\u30b6\u540d\u3068\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\uff09\u3092\u767b\u9332<\/span>\r\ngit config <span class=\"nt\">--global<\/span> user.name <span class=\"s2\">\"\u3010\u30e6\u30fc\u30b6\u540d\u3011\"<\/span>\r\ngit config <span class=\"nt\">--global<\/span> user.email \u3010\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3011\r\n\r\n<span class=\"c\"># \u30bf\u30fc\u30df\u30ca\u30eb\u3067\u51fa\u529b\u3059\u308b\u6587\u5b57\u306b\u8272\u4ed8\u3051\u3057\u305f\u3044\u5834\u5408<\/span>\r\ngit config <span class=\"nt\">--global<\/span> color.ui <span class=\"nb\">true<\/span>\r\n\r\n<span class=\"c\"># \u8a2d\u5b9a\u5185\u5bb9\u306e\u78ba\u8a8d<\/span>\r\ngit config <span class=\"nt\">-l<\/span>\r\ngit config <span class=\"nt\">--list<\/span>\r\n<\/code><\/pre>\n<h2>\u4e0d\u540c\u7684<\/h2>\n<p>\u786e\u8ba4\u5df2\u66f4\u6539\u6587\u4ef6\u7684\u5dee\u5f02<\/p>\n<pre class=\"post-pre\"><code><span class=\"c\"># \u5909\u66f4\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u3068\u30b9\u30c6\u30fc\u30b8\u30f3\u30b0\u30fb\u30a8\u30ea\u30a2\uff08git add \u672a\u5b9f\u884c\u306e\u72b6\u614b\uff09\u306e\u5dee\u5206\u3092\u78ba\u8a8d<\/span>\r\ngit diff\r\n\r\n<span class=\"c\"># \u30b9\u30c6\u30fc\u30b8\u30f3\u30b0\u30fb\u30a8\u30ea\u30a2\u3068\u30ea\u30dd\u30b8\u30c8\u30ea\uff08git commit \u672a\u5b9f\u884c\u306e\u72b6\u614b\uff09\u306e\u5dee\u5206\u3092\u78ba\u8a8d<\/span>\r\ngit diff <span class=\"nt\">--cached<\/span>\r\n<\/code><\/pre>\n<p>\u66f4\u6539index.html\u6587\u4ef6\u540e\uff0c\u6267\u884cgit add\u547d\u4ee4\u540e\u68c0\u67e5\u5dee\u5f02\u3002<\/p>\n<pre class=\"post-pre\"><code>$ git diff --cached\r\ndiff --git a\/index.html b\/index.html\r\nindex 732c3b4..e967372 100644\r\n--- a\/index.html\r\n+++ b\/index.html\r\n@@ -1 +1 @@\r\n- (\u30de\u30a4\u30ca\u30b9) \u304c\u524a\u9664\u3055\u308c\u305f\u884c  \u203b\u901a\u5e38\u306f\u8d64\u3067\u8868\u793a\r\n+ (\u30d7\u30e9\u30b9) \u304c\u8ffd\u52a0\u3055\u308c\u305f\u884c  \u203b\u901a\u5e38\u306f\u7dd1\u3067\u8868\u793a\r\n<\/code><\/pre>\n<h2>\u5e2e\u52a9<\/h2>\n<p>\u5e2e\u52a9\u67e5\u8be2<\/p>\n<pre class=\"post-pre\"><code>git <span class=\"nb\">help<\/span> \u3010\u30b3\u30de\u30f3\u30c9\u3011\r\ngit \u3010\u30b3\u30de\u30f3\u30c9\u3011 <span class=\"nt\">--help<\/span>\r\nman git-\u3010\u30b3\u30de\u30f3\u30c9\u3011\r\n\r\n<span class=\"c\"># ex. config \u30b3\u30de\u30f3\u30c9\u306e\u30d8\u30eb\u30d7\u3092\u53c2\u7167\u3059\u308b<\/span>\r\ngit <span class=\"nb\">help <\/span>config\r\n<\/code><\/pre>\n<h2>\u5f00\u59cb<\/h2>\n<p>\u5bf9\u73b0\u6709\u76ee\u5f55\u8fdb\u884c\u4ed3\u5e93\u521d\u59cb\u5316<\/p>\n<pre class=\"post-pre\"><code><span class=\"c\"># .git \u3068\u3044\u3046\u540d\u524d\u306e\u65b0\u3057\u3044\u30b5\u30d6\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304c\u4f5c\u3089\u308c\u3001\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u5fc5\u8981\u306a\u3059\u3079\u3066\u306e\u30d5\u30a1\u30a4\u30eb\u304c\u305d\u306e\u4e2d\u306b\u683c\u7d0d\u3055\u308c\u308b <\/span>\r\ngit init\r\n\r\n<span class=\"c\"># ex. \/home \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u7a7a\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u3092\u4f5c\u6210<\/span>\r\n<span class=\"nv\">$ <\/span><span class=\"nb\">cd<\/span> \/home\r\n<span class=\"nv\">$ <\/span>git init\r\nInitialized empty Git repository <span class=\"k\">in<\/span> \/home\/.git\/\r\n<\/code><\/pre>\n<h2>\u8bb0\u5f55<\/h2>\n<p>\u67e5\u770b\u63d0\u4ea4\u5386\u53f2<\/p>\n<pre class=\"post-pre\"><code><span class=\"c\"># \u3059\u3079\u3066\u306e\u30b3\u30df\u30c3\u30c8\u5c65\u6b74\u3092\u8868\u793a<\/span>\r\ngit log\r\n\r\n<span class=\"c\"># \u6700\u65b0\u306e\u30b3\u30df\u30c3\u30c8\u5c65\u6b74\u3092\uff11\u4ef6\u306e\u307f\u8868\u793a<\/span>\r\ngit log <span class=\"nt\">-1<\/span>\r\n\r\n<span class=\"c\"># \u3059\u3079\u3066\u306e\u30b3\u30df\u30c3\u30c8\u5c65\u6b74\u3092\uff11\u884c\u3067\u7c21\u6f54\u306b\u8868\u793a<\/span>\r\ngit log <span class=\"nt\">--oneline<\/span>\r\n\r\n<span class=\"c\"># \u30b3\u30df\u30c3\u30c8\u5c65\u6b74\u306b\u5909\u66f4\u5185\u5bb9\u3082\u8ffd\u52a0\u3057\u3066\u8868\u793a<\/span>\r\ngit log <span class=\"nt\">-p<\/span>\r\n<\/code><\/pre>\n<p>\u5728\u4f7f\u7528git log -p\u547d\u4ee4\u65f6\uff0c\u4f1a\u5c06\u5dee\u5f02\u547d\u4ee4\u7684\u5185\u5bb9\u6dfb\u52a0\u5230\u63d0\u4ea4\u8bb0\u5f55\u4e2d\u3002<\/p>\n<pre class=\"post-pre\"><code>$ git log -p\r\ncommit 9999999999999999999999999999999999999999\r\nAuthor: git-user &lt;git@user.com&gt;\r\nDate:   Tue Oct 10 10:20:20 2020 +0900\r\n\r\n    \u3010\u30b3\u30df\u30c3\u30c8\u30e1\u30c3\u30bb\u30fc\u30b8\u3011\r\n\r\ndiff --git a\/index.html b\/index.html\r\nindex 732c3b4..e967372 100644\r\n--- a\/index.html\r\n+++ b\/index.html\r\n@@ -1 +1 @@\r\n- (\u30de\u30a4\u30ca\u30b9) \u304c\u524a\u9664\u3055\u308c\u305f\u884c  \u203b\u901a\u5e38\u306f\u8d64\u3067\u8868\u793a\r\n+ (\u30d7\u30e9\u30b9) \u304c\u8ffd\u52a0\u3055\u308c\u305f\u884c  \u203b\u901a\u5e38\u306f\u7dd1\u3067\u8868\u793a\r\n: \u2190 \u8868\u793a\u5185\u5bb9\u304c\u591a\u3044\u5834\u5408\u3001\u2191\u2193\u30ad\u30fc\u3067\u30b9\u30af\u30ed\u30fc\u30eb\u3057\u3001Q\u30ad\u30fc\u3067\u7d42\u4e86\r\n<\/code><\/pre>\n<h2>\u62c9 (l\u0101)<\/h2>\n<p>\u5c06\u8fdc\u7a0b\u4ed3\u5e93\u7684\u5185\u5bb9\u5bfc\u5165\u5230\u5de5\u4f5c\u76ee\u5f55\u4e2d\u3002<\/p>\n<pre class=\"post-pre\"><code>git pull \u3010\u30ea\u30e2\u30fc\u30c8\u540d\u3011 \u3010\u30ed\u30fc\u30ab\u30eb\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u30d6\u30e9\u30f3\u30c1\u540d\u3011\r\n\r\n<span class=\"c\"># ex. origin \u3068\u3044\u3046\u30ea\u30e2\u30fc\u30c8\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u5185\u5bb9\u3092\u30ed\u30fc\u30ab\u30eb\u30ea\u30dd\u30b8\u30c8\u30ea\u306e primary \u30d6\u30e9\u30f3\u30c1\u306b\u53d6\u308a\u8fbc\u3080<\/span>\r\n<span class=\"nv\">$ <\/span>git pull origin primary\r\n<\/code><\/pre>\n<h2>\u63a8\u52a8<\/h2>\n<p>\u5c06\u672c\u5730\u4ed3\u5e93\u7684\u5185\u5bb9\u53d1\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93\u3002<\/p>\n<pre class=\"post-pre\"><code>git push \u3010\u30ea\u30e2\u30fc\u30c8\u540d\u3011 \u3010\u30ea\u30e2\u30fc\u30c8\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u30d6\u30e9\u30f3\u30c1\u540d\u3011\r\n\r\n<span class=\"c\"># ex. origin \u3068\u3044\u3046\u30ea\u30e2\u30fc\u30c8\u30ea\u30dd\u30b8\u30c8\u30ea\u306e primary \u30d6\u30e9\u30f3\u30c1\u306b\u30ed\u30fc\u30ab\u30eb\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u5185\u5bb9\u3092\u9001\u4fe1<\/span>\r\n<span class=\"nv\">$ <\/span>git push origin primary\r\n<\/code><\/pre>\n<h2>\u9065\u8fdc\u7684<\/h2>\n<p>\u663e\u793a\u8fdc\u7a0b\u5b58\u50a8\u5e93\u7684\u540d\u79f0<\/p>\n<pre class=\"post-pre\"><code>git remote\r\n\r\n<span class=\"c\"># \u30ea\u30e2\u30fc\u30c8\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u540d\u524d\u3068\u5834\u6240\uff08URL\uff09\u3092\u8868\u793a<\/span>\r\ngit remote <span class=\"nt\">-v<\/span>\r\n<\/code><\/pre>\n<p>\u6dfb\u52a0\u8fdc\u7a0b\u4ed3\u5e93<\/p>\n<pre class=\"post-pre\"><code>git remote add  \u3010\u30ea\u30e2\u30fc\u30c8\u540d\u3011 \u3010\u30ea\u30e2\u30fc\u30c8\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u5834\u6240\uff08URL\uff09\u3011\r\n\r\n<span class=\"c\"># ex. \u73fe\u5728\u306e\u30ed\u30fc\u30ab\u30eb\u30ea\u30dd\u30b8\u30c8\u30ea\u306b orgin \u3068\u3044\u3046\u540d\u524d\u3067 https:\/\/remote.repos\/itory \u3092\u8ffd\u52a0<\/span>\r\n<span class=\"nv\">$ <\/span>git remote add origin https:\/\/remote.repos\/itory\r\n<\/code><\/pre>\n<p>\u5220\u9664\u8fdc\u7a0b\u4ee3\u7801\u5e93<\/p>\n<pre class=\"post-pre\"><code>git remote <span class=\"nb\">rm<\/span> \u3010\u30ea\u30e2\u30fc\u30c8\u540d\u3011\r\n<\/code><\/pre>\n<p>\u66f4\u6539\u8fdc\u7a0b\u540d\u79f0<\/p>\n<pre class=\"post-pre\"><code>git remote rename  \u3010\u73fe\u5728\u306e\u30ea\u30e2\u30fc\u30c8\u540d\u3011 \u3010\u65b0\u3057\u3044\u30ea\u30e2\u30fc\u30c8\u540d\u3011\r\n<\/code><\/pre>\n<h2>\u91cd\u7f6e<\/h2>\n<p>\u4ece\u6682\u5b58\u533a\u4e2d\u5220\u9664\u6240\u6709\u6587\u4ef6\uff08\u64a4\u9500add\u547d\u4ee4\uff09\u3002<\/p>\n<pre class=\"post-pre\"><code>git reset\r\n<\/code><\/pre>\n<p>\u5c06\u6240\u6709\u6dfb\u52a0\u5230\u5206\u7ec4\u6587\u4ef6\u5939\u7684\u6587\u4ef6\u5220\u9664<\/p>\n<pre class=\"post-pre\"><code>$ git status\r\n# On branch primary\r\n# Changes to be committed:\r\n#   (use \"git reset HEAD &lt;file&gt;...\" to unstage)\r\n#\r\n#       modified:   index.html\r\n#       modified:   style.css\r\n<\/code><\/pre>\n<p>\u3010\u5de5\u4f5c\u76ee\u9304\u3011<br \/>\n\u2193<br \/>\n\u65b0\u589e<br \/>\n\u2193<br \/>\n\u3010\u66ab\u5b58\u5340\u3011\u3000index.html\u3000style.css<\/p>\n<pre class=\"post-pre\"><code>$ git reset\r\nUnstaged changes after reset:\r\nM       index.html\r\nM       style.css\r\n<\/code><\/pre>\n<p>\u3010\u5de5\u4f5c\u76ee\u5f55\u3011<br \/>\n\u2193\u2003\u2003\u2003\u2003\u2003\u2003\u2191<br \/>\n\u6dfb\u52a0\u2003\u2003\u2003\u2003\u91cd\u7f6e\u2003\u2003index.html\u2003style.css<br \/>\n\u2193\u2003\u2003\u2003\u2003\u2003\u2003\u2191<br \/>\n\u3010\u6682\u5b58\u533a\u3011<\/p>\n<pre class=\"post-pre\"><code>$ git status\r\n# On branch primary\r\n# Changes not staged for commit:\r\n#   (use \"git add &lt;file&gt;...\" to update what will be committed)\r\n#   (use \"git checkout -- &lt;file&gt;...\" to discard changes in working directory)\r\n#\r\n#       modified:   index.html\r\n#       modified:   style.css\r\n<\/code><\/pre>\n<p>\u3010\u5de5\u4f5c\u76ee\u5f55\u3011index.html style.css<br \/>\n\u2193 \u2191<br \/>\n\u6dfb\u52a0 \u91cd\u7f6e<br \/>\n\u2193 \u2191<br \/>\n\u3010\u6682\u5b58\u533a\u3011<\/p>\n<h2>\u91cd\u7f6e\u3010\u6587\u4ef6\u3011<\/h2>\n<p>\u4ece\u6682\u5b58\u533a\u5220\u9664\u3010\u6587\u4ef6\u3011\uff08\u64a4\u9500add\u547d\u4ee4\uff09<\/p>\n<pre class=\"post-pre\"><code>git reset \u3010\u30d5\u30a1\u30a4\u30eb\u3011\r\n<\/code><\/pre>\n<p>\u4ece\u5df2\u6dfb\u52a0\u5230Staging Area\u7684\u6587\u4ef6\u4e2d\uff0c\u4ec5\u79fb\u9664 style.css\u3002<\/p>\n<pre class=\"post-pre\"><code>$ git status\r\n# On branch primary\r\n# Changes to be committed:\r\n#   (use \"git reset HEAD &lt;file&gt;...\" to unstage)\r\n#\r\n#       modified:   index.html\r\n#       modified:   style.css\r\n<\/code><\/pre>\n<p>\u3010\u5de5\u4f5c\u76ee\u5f55\u3011<br \/>\n\u2193<br \/>\n\u65b0\u589e<br \/>\n\u2193<br \/>\n\u3010\u6682\u5b58\u533a\u57df\u3011\u2003index.html\u2003style.css<\/p>\n<pre class=\"post-pre\"><code>$ git reset style.css\r\nUnstaged changes after reset:\r\nM       style.css\r\n<\/code><\/pre>\n<p>\u3010\u5de5\u4f5c\u76ee\u5f55\u3011<br \/>\n\u2193 \u2191<br \/>\n\u6dfb\u52a0 \u91cd\u7f6e style.css<br \/>\n\u2193 \u2191<br \/>\n\u3010\u6682\u5b58\u533a\u3011 index.html<\/p>\n<pre class=\"post-pre\"><code>$ git status\r\n# On branch primary\r\n# Changes to be committed:\r\n#   (use \"git reset HEAD &lt;file&gt;...\" to unstage)\r\n#\r\n#       modified:   index.html\r\n#\r\n# Changes not staged for commit:\r\n#   (use \"git add &lt;file&gt;...\" to update what will be committed)\r\n#   (use \"git checkout -- &lt;file&gt;...\" to discard changes in working directory)\r\n#\r\n#       modified:   style.css\r\n<\/code><\/pre>\n<p>\u3010\u5de5\u4f5c\u76ee\u5f55\u3011\u2003style.css<br \/>\n\u2193\u2003\u2003\u2003\u2003\u2003\u2003\u2191<br \/>\n\u6dfb\u52a0\u2003\u2003\u2003\u91cd\u7f6e<br \/>\n\u2193\u2003\u2003\u2003\u2003\u2003\u2003\u2191<br \/>\n\u3010\u6682\u5b58\u533a\u3011\u2003index.html<\/p>\n<h2>\u56de\u9000 &#8211;soft HEAD^<\/h2>\n<p>\u64a4\u9500\u6700\u65b0\u7684\u63d0\u4ea4\u547d\u4ee4<\/p>\n<p>\u5728\u4e2d\u6587\u4e2d\uff0c&#8221;HEAD&#8221;\u8868\u793a\u6700\u65b0\u7684\u63d0\u4ea4\u4f4d\u7f6e\uff0c&#8221;HEAD^&#8221;\u8868\u793a\u524d\u4e00\u4e2a\u63d0\u4ea4\u4f4d\u7f6e\u3002<\/p>\n<pre class=\"post-pre\"><code>git reset <span class=\"nt\">--soft<\/span> HEAD^ \r\n<\/code><\/pre>\n<p>index.html \u64a4\u9500\u6700\u8fd1\u7684\u66f4\u65b0\u63d0\u4ea4\uff0c\u5e76\u5c06index.html \u6587\u4ef6\u91cd\u65b0\u653e\u56de\u6682\u5b58\u533a\u3002<\/p>\n<pre class=\"post-pre\"><code>$ git status\r\n# On branch primary\r\n# Changes to be committed:\r\n#   (use \"git reset HEAD &lt;file&gt;...\" to unstage)\r\n#\r\n#       modified:   index.html\r\n<\/code><\/pre>\n<p>\u3010\u6682\u5b58\u533a\u3011 index.html<br \/>\n\u2193<br \/>\n\u63d0\u4ea4<br \/>\n\u2193<br \/>\n\u3010\u672c\u5730\u4ee3\u7801\u5e93\u3011<\/p>\n<pre class=\"post-pre\"><code>$ git commit -m \"index.html \u3092\u66f4\u65b0\"\r\n[primary 9999999] index.html \u3092\u66f4\u65b0\r\n 1 file changed, 2 insertions(+)\r\n\r\n$ git log -1\r\ncommit 9999999999999999999999999999999999999999\r\nAuthor: git-user &lt;git@user.com&gt;\r\nDate:   Tue Oct 10 10:20:20 2020 +0900\r\n\r\n    index.html \u3092\u66f4\u65b0\r\n<\/code><\/pre>\n<p>\u3010\u6682\u5b58\u533a\u3011<br \/>\n\u2193<br \/>\n\u63d0\u4ea4<br \/>\n\u2193<br \/>\n\u3010\u672c\u5730\u4ee3\u7801\u5e93\u3011 index.html<\/p>\n<pre class=\"post-pre\"><code>$ git reset --soft HEAD^\r\n\r\n$ git status\r\n# On branch primary\r\n# Changes to be committed:\r\n#   (use \"git reset HEAD &lt;file&gt;...\" to unstage)\r\n#\r\n#       modified:   index.html\r\n#\r\n\r\n$ git log -1\r\ncommit 0000000000000000000000000000000000000000\r\nAuthor: git-user &lt;git@user.com&gt;\r\nDate:   Tue Oct 10 10:10:10 2020 +0900\r\n\r\n    index.html \u3092\u66f4\u65b0 \u306e\u3072\u3068\u3064\u524d\u306e\u30b3\u30df\u30c3\u30c8\u5c65\u6b74\r\n<\/code><\/pre>\n<p>\u3010\u6682\u5b58\u533a\u3011index.html<br \/>\n\u2193\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u2191<br \/>\n\u63d0\u4ea4\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u64a4\u9500\u8f6f\u56de\u9000\u5230\u524d\u4e00\u4e2a\u7248\u672c<br \/>\n\u2193\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u2191<br \/>\n\u3010\u672c\u5730\u4ee3\u7801\u5e93\u3011<\/p>\n<h2>\u5c06\u4ee3\u7801\u56de\u6eda\u5230\u4e0a\u4e00\u4e2a\u63d0\u4ea4\u3002<\/h2>\n<p>\u64a4\u9500\u6700\u65b0\u7684 commit \u547d\u4ee4\u5386\u53f2\uff08\u5305\u62ec\u4f5c\u4e1a\u76ee\u5f55\u548c\u6682\u5b58\u533a\u7684\u6240\u6709\u66f4\u6539\u64cd\u4f5c\uff09\u3002<\/p>\n<p>\u203b HEAD \u662f\u6307\u6700\u65b0\u63d0\u4ea4\u7684\u4f4d\u7f6e\uff0cHEAD^ \u662f\u6307\u524d\u4e00\u4e2a\u63d0\u4ea4\u4f4d\u7f6e\u7684\u610f\u601d\u3002<\/p>\n<pre class=\"post-pre\"><code>git reset <span class=\"nt\">--hard<\/span> HEAD^ \r\n<\/code><\/pre>\n<p>\u66f4\u65b0index.html\u6587\u4ef6\u7684\u63d0\u4ea4\u5e76\u64a4\u9500\uff0c\u5c06\u6240\u6709\u5185\u5bb9\u6062\u590d\u5230\u4e0a\u4e00\u4e2a\u63d0\u4ea4\u7684\u72b6\u6001\u3002<\/p>\n<pre class=\"post-pre\"><code>$ cat -n index.html\r\n     1  reset --hard HEAD^ \u5b9f\u884c\u524d\u306e\u72b6\u614b\r\n     2  reset --hard HEAD^ \u5b9f\u884c\u306b\u3088\u3063\u3066\u3001\u3053\u306e\u884c\uff08\uff12\u884c\u76ee\uff09\u306e\u8ffd\u52a0\u306f\u53d6\u308a\u6d88\u3055\u308c\u308b\r\n<\/code><\/pre>\n<p>\u3010\u5de5\u4f5c\u76ee\u5f55\u3011\u5728index.html\u4e2d\u6dfb\u52a0\u7b2c\u4e8c\u884c<br \/>\n\u2193<br \/>\n\u52a0<br \/>\n\u2193<br \/>\n\u3010\u6682\u5b58\u533a\u3011<br \/>\n\u2193<br \/>\n\u63d0\u4ea4<br \/>\n\u2193<br \/>\n\u3010\u672c\u5730\u4ed3\u5e93\u3011index.html\u4e2d\u6dfb\u52a0\u4e86\u7b2c\u4e8c\u884c<\/p>\n<pre class=\"post-pre\"><code>$ git reset --hard HEAD^\r\nHEAD is now at 0000000 index.html \u3092\u66f4\u65b0 \u306e\u3072\u3068\u3064\u524d\u306e\u30b3\u30df\u30c3\u30c8\u5c65\u6b74\r\n\r\n$ cat -n index.html\r\n     1  reset --hard HEAD^ \u5b9f\u884c\u524d\u306e\u72b6\u614b\r\n<\/code><\/pre>\n<p>\u3010\u4f5c\u4e1a\u76ee\u5f55\u3011\uff1a\u5728index.html\u6587\u4ef6\u7684\u7b2c\u4e8c\u884c\u6dfb\u52a0\u65b0\u5185\u5bb9<br \/>\n\u2191<br \/>\n\u6dfb\u52a0<br \/>\n\u2191<br \/>\n\u3010\u6682\u5b58\u533a\u3011<br \/>\n\u2191<br \/>\n\u63d0\u4ea4<br \/>\n\u2191<br \/>\nreset &#8211;hard HEAD^<br \/>\n\u2191<br \/>\n\u3010\u672c\u5730\u4ed3\u5e93\u3011\uff1aindex.html\u6587\u4ef6\u4e2d\u672a\u6dfb\u52a0\u7b2c\u4e8c\u884c\u5185\u5bb9<\/p>\n<h2>\u91cd\u7f6e &#8212; \u5f3a\u5236 HEAD<\/h2>\n<p>\u64a4\u9500\u6700\u65b0\u7684\u63d0\u4ea4\u547d\u4ee4\u6267\u884c\u540e\uff0c\u5728\u5de5\u4f5c\u76ee\u5f55\u548c\u6682\u5b58\u533a\uff08\u5305\u62ecadd\u547d\u4ee4\uff09\u4e2d\u7684\u6240\u6709\u64cd\u4f5c\u3002<\/p>\n<p>\u203b HEAD \u6307\u7684\u662f\u6700\u65b0\u7684\u63d0\u4ea4\u4f4d\u7f6e<\/p>\n<pre class=\"post-pre\"><code>git reset <span class=\"nt\">--hard<\/span> HEAD\r\n<\/code><\/pre>\n<p>\u5c06index.html\u6587\u4ef6\u66f4\u65b0\u5185\u5bb9\u56de\u9000\uff0c\u5e76\u5c06\u5de5\u4f5c\u76ee\u5f55\u548c\u6682\u5b58\u533a\u6062\u590d\u5230\u6700\u65b0\u7684\u63d0\u4ea4\u72b6\u6001\u3002<\/p>\n<pre class=\"post-pre\"><code>$ cat -n index.html\r\n     1  reset --hard HEAD \u5b9f\u884c\u524d\u306e\u72b6\u614b\r\n     2  reset --hard HEAD \u5b9f\u884c\u306b\u3088\u3063\u3066\u3001\u3053\u306e\u884c\uff08\uff12\u884c\u76ee\uff09\u306e\u8ffd\u52a0\u306f\u53d6\u308a\u6d88\u3055\u308c\u308b\r\n<\/code><\/pre>\n<p>\u3010\u4f5c\u696d\u76ee\u5f55\u3011\u5728 index.html \u4e0a\u6dfb\u52a0\u7b2c\u4e8c\u884c<br \/>\n\u2193<br \/>\n\u6dfb\u52a0<br \/>\n\u2193<br \/>\n\u3010\u6682\u5b58\u533a\u3011index.html \u6dfb\u52a0\u4e86\u7b2c\u4e8c\u884c<\/p>\n<pre class=\"post-pre\"><code>$ git reset --hard HEAD\r\nHEAD is now at 0000000 index.html \u3092\u66f4\u65b0 \u306e\u3072\u3068\u3064\u524d\u306e\u30b3\u30df\u30c3\u30c8\u5c65\u6b74\r\n\r\n$ cat -n index.html\r\n     1  reset --hard HEAD \u5b9f\u884c\u524d\u306e\u72b6\u614b\r\n<\/code><\/pre>\n<p>\u3010\u5de5\u4f5c\u76ee\u5f55\u3011\u5728 index.html \u6587\u4ef6\u4e2d\u6dfb\u52a0\u7b2c\u4e8c\u884c\u3002<br \/>\n\u2191<br \/>\n\u6dfb\u52a0<br \/>\n\u2191<br \/>\n\u91cd\u7f6e &#8211;hard HEAD<br \/>\n\u2191<br \/>\n\u3010\u6682\u5b58\u533a\u3011index.html \u6587\u4ef6\u5df2\u7ecf\u6dfb\u52a0\u7b2c\u4e8c\u884c\u3002<\/p>\n<h2>\u91cd\u7f6e&#8211;hard\u7684HEAD^\u548cHEAD\u4e4b\u95f4\u7684\u533a\u522b<\/h2>\n<p>\u6700\u65b0\u7684\u63d0\u4ea4\u8bb0\u5f55\u6709\u4ee5\u4e0b\u4e24\u4e2a\uff1a<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span>git log <span class=\"nt\">--oneline<\/span> <span class=\"nt\">-2<\/span>\r\n9999999 index.html \u3092\u66f4\u65b0\r\n0000000 index.html \u3092\u4f5c\u6210\r\n<\/code><\/pre>\n<p>\u5f53\u5728\u821e\u53f0\u533a\u57df\u6dfb\u52a0\u4e86style.css\u65f6\u3002<\/p>\n<pre class=\"post-pre\"><code>$ git status\r\n# On branch primary\r\n# Changes to be committed:\r\n#   (use \"git reset HEAD &lt;file&gt;...\" to unstage)\r\n#\r\n#       modified:   style.css\r\n<\/code><\/pre>\n<h4>\u5982\u679c\u6267\u884c reset &#8211;hard HEAD^ \u7684\u8bdd<\/h4>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span>git reset <span class=\"nt\">--hard<\/span> HEAD^\r\nHEAD is now at 0000000 index.html \u3092\u4f5c\u6210\r\n\r\n<span class=\"c\"># \u6700\u65b0\u306e\u30b3\u30df\u30c3\u30c8\u5c65\u6b74 \u300c9999999 index.html \u3092\u66f4\u65b0\u300d \u304c\u53d6\u308a\u6d88\u3055\u308c\u308b<\/span>\r\n<span class=\"nv\">$ <\/span>git log <span class=\"nt\">--oneline<\/span> <span class=\"nt\">-2<\/span>\r\n0000000 index.html \u3092\u4f5c\u6210\r\n1111111 index.html \u3092\u4f5c\u6210 \u306e\u3072\u3068\u3064\u524d\u306e\u30b3\u30df\u30c3\u30c8\u5c65\u6b74\r\n<\/code><\/pre>\n<p>\u5c06 style.css \u6587\u4ef6\u7684\u63d0\u4ea4\u6dfb\u52a0\u4e5f\u88ab\u64a4\u9500<\/p>\n<pre class=\"post-pre\"><code>$ git status\r\n# On branch primary\r\nnothing to commit, working directory clean\r\n<\/code><\/pre>\n<h4>\u5982\u679c\u6267\u884c `reset &#8211;hard HEAD`\u3002<\/h4>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span>git reset <span class=\"nt\">--hard<\/span> HEAD\r\nHEAD is now at 9999999 index.html \u3092\u66f4\u65b0\r\n\r\n<span class=\"c\"># \u6700\u65b0\u306e\u30b3\u30df\u30c3\u30c8\u5c65\u6b74\u306f\u5909\u5316\u306a\u3057<\/span>\r\n<span class=\"nv\">$ <\/span>git log <span class=\"nt\">--oneline<\/span> <span class=\"nt\">-2<\/span>\r\n9999999 index.html \u3092\u66f4\u65b0\r\n0000000 index.html \u3092\u4f5c\u6210\r\n<\/code><\/pre>\n<p>\u53ea\u53d6\u6d88\u5bf9style.css\u6587\u4ef6\u6dfb\u52a0\u5230\u6682\u5b58\u533a\u4e2d\u7684\u64cd\u4f5c\u3002<\/p>\n<pre class=\"post-pre\"><code>$ git status\r\n# On branch primary\r\nnothing to commit, working directory clean\r\n<\/code><\/pre>\n<h2>\u91cd\u7f6e &#8212; \u5f3a\u5236 ORIG_HEAD<\/h2>\n<p>\u53d6\u6d88\u6700\u8fd1\u7684\u91cd\u7f6e<\/p>\n<pre class=\"post-pre\"><code>git reset <span class=\"nt\">--hard<\/span> ORIG_HEAD\r\n<\/code><\/pre>\n<p>\u53d6\u6d88\u64a4\u9500\u76f4\u524d\u7684\u63d0\u4ea4\u8bb0\u5f55\u201c9999999 \u66f4\u65b0\u4e86index.html\u201d\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"c\"># \u6700\u65b0\uff12\u4ef6\u306e\u30b3\u30df\u30c3\u30c8\u5c65\u6b74\u3092\u78ba\u8a8d<\/span>\r\n<span class=\"nv\">$ <\/span>git log <span class=\"nt\">--oneline<\/span> <span class=\"nt\">-2<\/span>\r\n9999999 index.html \u3092\u66f4\u65b0\r\n0000000 index.html \u3092\u66f4\u65b0 \u306e\u3072\u3068\u3064\u524d\u306e\u30b3\u30df\u30c3\u30c8\u5c65\u6b74\r\n\r\n<span class=\"c\"># \u6700\u65b0\u306e\u30b3\u30df\u30c3\u30c8\u5c65\u6b74\u3092\u53d6\u308a\u6d88\u3057<\/span>\r\n<span class=\"nv\">$ <\/span>git reset <span class=\"nt\">--hard<\/span> HEAD^\r\nHEAD is now at 0000000 index.html \u3092\u66f4\u65b0 \u306e\u3072\u3068\u3064\u524d\u306e\u30b3\u30df\u30c3\u30c8\u5c65\u6b74\r\n\r\n<span class=\"c\"># \u6700\u65b0\uff12\u4ef6\u306e\u30b3\u30df\u30c3\u30c8\u5c65\u6b74\u3092\u78ba\u8a8d<\/span>\r\n<span class=\"nv\">$ <\/span>git log <span class=\"nt\">--oneline<\/span> <span class=\"nt\">-2<\/span>\r\n0000000 index.html \u3092\u66f4\u65b0 \u306e\u3072\u3068\u3064\u524d\u306e\u30b3\u30df\u30c3\u30c8\u5c65\u6b74\r\n1111111 index.html \u3092\u66f4\u65b0 \u306e\u3075\u305f\u3064\u524d\u306e\u30b3\u30df\u30c3\u30c8\u5c65\u6b74\r\n\r\n<span class=\"c\"># \u6700\u65b0\u306e\u30b3\u30df\u30c3\u30c8\u5c65\u6b74\u306e\u53d6\u308a\u6d88\u3057\u3092\u53d6\u308a\u6d88\u3057<\/span>\r\n<span class=\"nv\">$ <\/span>git reset <span class=\"nt\">--hard<\/span> ORIG_HEAD\r\nHEAD is now at 9999999 index.html \u3092\u66f4\u65b0\r\n\r\n<span class=\"c\"># \u6700\u65b0\uff12\u4ef6\u306e\u30b3\u30df\u30c3\u30c8\u5c65\u6b74\u3092\u78ba\u8a8d<\/span>\r\n<span class=\"nv\">$ <\/span>git log <span class=\"nt\">--oneline<\/span> <span class=\"nt\">-2<\/span>\r\n9999999 index.html \u3092\u66f4\u65b0\r\n0000000 index.html \u3092\u66f4\u65b0 \u306e\u3072\u3068\u3064\u524d\u306e\u30b3\u30df\u30c3\u30c8\u5c65\u6b74\r\n<\/code><\/pre>\n<h2>\u72b6\u6001<\/h2>\n<p>\u786e\u8ba4\u6bcf\u4e2a\u6587\u4ef6\u5904\u4e8e\u4ec0\u4e48\u72b6\u6001<\/p>\n<pre class=\"post-pre\"><code>git status\r\n<\/code><\/pre>\n<p>index.html \u5df2\u88ab\u66f4\u65b0\uff0c\u4f46\u5c1a\u672a\u6dfb\u52a0\u5230\u6682\u5b58\u533a\uff08\u672a\u6267\u884c git add \u548c git commit\uff09\u3002<\/p>\n<pre class=\"post-pre\"><code>$ git status\r\nOn branch primary\r\nChanges not staged for commit:\r\n  (use \"git add &lt;file&gt;...\" to update what will be committed)\r\n  (use \"git checkout -- &lt;file&gt;...\" to discard changes in working directory)\r\n\r\n      modified:   index.html\r\n<\/code><\/pre>\n<p>style.css\u5df2\u6dfb\u52a0\u5230\u6682\u5b58\u533a\uff0c\u4f46\u5c1a\u672a\u63d0\u4ea4\u5230\u4ee3\u7801\u5e93\uff08\u5df2\u6267\u884cgit add\uff0c\u4f46\u672a\u6267\u884cgit commit\uff09\u3002<\/p>\n<pre class=\"post-pre\"><code>$ git status\r\nOn branch primary\r\nChanges to be committed:\r\n  (use \"git reset HEAD &lt;file&gt;...\" to unstage)\r\n\r\n      new file:   style.css\r\n<\/code><\/pre>\n<p>script.js \u5df2\u7ecf\u521b\u5efa\u4e86\uff0c\u4f46\u5c1a\u672a\u6dfb\u52a0\u5230\u6682\u5b58\u533a\u3002\uff08\u65b0\u521b\u5efa\u7684\u6587\u4ef6\u6ca1\u6709\u6267\u884c git add \u548c git commit\uff09<\/p>\n<pre class=\"post-pre\"><code>$ git status\r\nUntracked files:\r\n  (use \"git add &lt;file&gt;...\" to include in what will be committed)\r\n\r\n      script.js\r\n<\/code><\/pre>\n<p>\u3010\u53c2\u8003\u3011<br \/>\nhttps:\/\/git-scm.com\/book\/ja\/<br \/>\nhttps:\/\/backlog.com\/ja\/git-tutorial\/<\/p>\n<p>\u3010\u53c2\u8003\u8d44\u6599\u3011<br \/>\nhttps:\/\/git-scm.com\/book\/zh\/<br \/>\nhttps:\/\/backlog.com\/zh\/git-tutorial\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Git\u7684\u57fa\u7840\u77e5\u8bc6 \u4f5c\u696d\u76ee\u5f55\u6216\u5de5\u4f5c\u533a &#8211; \u5728\u8fdb\u884c\u5b9e\u9645\u64cd\u4f5c\u7684\u76ee\u5f55 \u2191 \u6dfb\u52a0 \u2191 \u2191 \u6682\u5b58\u533a\u6216\u7d22\u5f15 \u2191  [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-37233","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Git\u547d\u4ee4 - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/git\u547d\u4ee4-3\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Git\u547d\u4ee4\" \/>\n<meta property=\"og:description\" content=\"Git\u7684\u57fa\u7840\u77e5\u8bc6 \u4f5c\u696d\u76ee\u5f55\u6216\u5de5\u4f5c\u533a &#8211; \u5728\u8fdb\u884c\u5b9e\u9645\u64cd\u4f5c\u7684\u76ee\u5f55 \u2191 \u6dfb\u52a0 \u2191 \u2191 \u6682\u5b58\u533a\u6216\u7d22\u5f15 \u2191 [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/git\u547d\u4ee4-3\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-05-04T15:35:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-29T02:58:28+00:00\" \/>\n<meta name=\"author\" content=\"\u96c5, \u609f\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u96c5, \u609f\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/git%e5%91%bd%e4%bb%a4-3\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/git%e5%91%bd%e4%bb%a4-3\/\",\"name\":\"Git\u547d\u4ee4 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-05-04T15:35:01+00:00\",\"dateModified\":\"2024-04-29T02:58:28+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/f044a4b7fa4ee2701702942002419ca6\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/git%e5%91%bd%e4%bb%a4-3\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/git%e5%91%bd%e4%bb%a4-3\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/git%e5%91%bd%e4%bb%a4-3\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Git\u547d\u4ee4\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/f044a4b7fa4ee2701702942002419ca6\",\"name\":\"\u96c5, \u609f\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/e71a913e914f1aad1efc391f92084294bac54bc782acd289638580134cf667a6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/e71a913e914f1aad1efc391f92084294bac54bc782acd289638580134cf667a6?s=96&d=mm&r=g\",\"caption\":\"\u96c5, \u609f\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/yawu\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/git%e5%91%bd%e4%bb%a4-3\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Git\u547d\u4ee4 - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/git\u547d\u4ee4-3\/","og_locale":"zh_CN","og_type":"article","og_title":"Git\u547d\u4ee4","og_description":"Git\u7684\u57fa\u7840\u77e5\u8bc6 \u4f5c\u696d\u76ee\u5f55\u6216\u5de5\u4f5c\u533a &#8211; \u5728\u8fdb\u884c\u5b9e\u9645\u64cd\u4f5c\u7684\u76ee\u5f55 \u2191 \u6dfb\u52a0 \u2191 \u2191 \u6682\u5b58\u533a\u6216\u7d22\u5f15 \u2191 [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/git\u547d\u4ee4-3\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-05-04T15:35:01+00:00","article_modified_time":"2024-04-29T02:58:28+00:00","author":"\u96c5, \u609f","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u96c5, \u609f","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/git%e5%91%bd%e4%bb%a4-3\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/git%e5%91%bd%e4%bb%a4-3\/","name":"Git\u547d\u4ee4 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-05-04T15:35:01+00:00","dateModified":"2024-04-29T02:58:28+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/f044a4b7fa4ee2701702942002419ca6"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/git%e5%91%bd%e4%bb%a4-3\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/git%e5%91%bd%e4%bb%a4-3\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/git%e5%91%bd%e4%bb%a4-3\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"Git\u547d\u4ee4"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/f044a4b7fa4ee2701702942002419ca6","name":"\u96c5, \u609f","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/e71a913e914f1aad1efc391f92084294bac54bc782acd289638580134cf667a6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e71a913e914f1aad1efc391f92084294bac54bc782acd289638580134cf667a6?s=96&d=mm&r=g","caption":"\u96c5, \u609f"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/yawu\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/git%e5%91%bd%e4%bb%a4-3\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/37233","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=37233"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/37233\/revisions"}],"predecessor-version":[{"id":84865,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/37233\/revisions\/84865"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=37233"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=37233"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=37233"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}