{"id":37358,"date":"2023-10-15T04:19:21","date_gmt":"2023-07-24T06:58:58","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/git%e5%92%8cgithub%e5%85%a5%e9%97%a8%ef%bc%883-3%ef%bc%89\/"},"modified":"2024-05-04T04:16:44","modified_gmt":"2024-05-03T20:16:44","slug":"git%e5%92%8cgithub%e5%85%a5%e9%97%a8%ef%bc%883-3%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/git%e5%92%8cgithub%e5%85%a5%e9%97%a8%ef%bc%883-3%ef%bc%89\/","title":{"rendered":"Git\u548cGitHub\u5165\u95e8\uff083\/3\uff09"},"content":{"rendered":"<h1>\u4e4b\u524d\u7684\u6587\u7ae0\u5728\u9019\u88e1\u3002<\/h1>\n<p>Git\u548cGitHub\u5165\u95e8\uff081\/3\uff09<br \/>\nGit\u548cGitHub\u5165\u95e8\uff082\/3\uff09<\/p>\n<h1>\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\u5e94\u8be5\u600e\u4e48\u529e\uff1f<\/h1>\n<p>\u56e0\u4e3a\u7ecf\u5e38\u6709\u5728\u5de5\u4f5c\u4e2d\u51fa\u73b0\u7684\u573a\u666f\uff0c\u6240\u4ee5\u8ba9\u6211\u4eec\u4e00\u8d77\u7ec3\u4e60\u4e00\u4e0b\u5427\u3002<\/p>\n<h2>\u53d6\u6d88\u5bf9\u6682\u5b58\u533a\u7684\u6dfb\u52a0<\/h2>\n<p>\u5982\u679c\u4e0d\u5c0f\u5fc3\u628a\u6587\u4ef6\u52a0\u5230\u4e86\u6682\u5b58\u533a\uff0c\u4f46\u63a5\u4e0b\u6765\u7684\u63d0\u4ea4\u4e2d\u53c8\u4e0d\u60f3\u5305\u542b\u5b83\uff0c\u8fd9\u79cd\u60c5\u51b5\u3002<\/p>\n<p>\u8bd5\u8bd5\u628a\u6587\u4ef6\u300ctest2\u300d\u6dfb\u52a0\u5230\u6682\u5b58\u533a\u3002<\/p>\n<pre class=\"post-pre\"><code>$ git add test2\r\n$ git status\r\nOn branch master\r\nChanges to be committed:\r\n  (use \"git reset HEAD &lt;file&gt;...\" to unstage)\r\n\r\n    new file:   test2\r\n<\/code><\/pre>\n<p>\u7b54\u6848\u5df2\u7ecf\u663e\u793a\u51fa\u6765\u4e86\u3002<br \/>\n\uff08\u4f7f\u7528\u201cgit reset HEAD &#8230;\u201d\u6765\u53d6\u6d88\u6682\u5b58\uff09<\/p>\n<p>\u6309\u7167\u5bfc\u822a\u63d0\u793a\uff0c\u5c06test2\u4ece\u5206\u5e03\u73af\u5883\u8fd8\u539f\u3002<\/p>\n<pre class=\"post-pre\"><code>$ git reset HEAD test2\r\n$ git status\r\nOn branch master\r\nUntracked files:\r\n  (use \"git add &lt;file&gt;...\" to include in what will be committed)\r\n\r\n    test2\r\n\r\nnothing added to commit but untracked files present (use \"git add\" to track)\r\n<\/code><\/pre>\n<p>\u5728\u5c06\u5176\u6dfb\u52a0\u5230\u6682\u5b58\u533a\u4e4b\u524d\uff0c\u4f60\u5df2\u7ecf\u56de\u5230\u4e86\u539f\u6765\u7684\u72b6\u6001\u3002<br \/>\n\u5728\u8fd9\u91cc\uff0c\u51fa\u73b0\u4e86\u4e00\u4e2a\u65b0\u8bcd\u3002 &#8220;HEAD&#8221; \u662f\u6307\u4ec0\u4e48\u5462\uff1f<\/p>\n<h3>\u5934\u662f\u4ec0\u4e48<\/h3>\n<p>HEAD\u662f\u6307\u5f53\u524d\u5de5\u4f5c\u5206\u652f\u7684\u6700\u65b0\u63d0\u4ea4\u3002<br \/>\n\u6211\u4eec\u53ef\u4ee5\u7528git log\u547d\u4ee4\u6765\u67e5\u770b\u63d0\u4ea4\u65e5\u5fd7\u3002<\/p>\n<pre class=\"post-pre\"><code>$ git log\r\ncommit 7022b44cb174e7d1d932a950d052fcdec9b36408 (HEAD -&gt; master, origin\/master)\r\nAuthor: hoge &lt;53826023+hoge@users.noreply.github.com&gt;\r\nDate:   Sat Oct 12 22:15:23 2019 +0900\r\n\r\n    Create README.md\r\n\r\ncommit f733bfe11003832f28f4803481cbe086e1903e4a\r\nAuthor: hoge &lt;hoge@gmail.com&gt;\r\nDate:   Sat Oct 12 19:13:31 2019 +0900\r\n\r\n    first commit\r\n<\/code><\/pre>\n<p>\u73b0\u5728\uff0cHEAD\u6307\u5411\u6700\u65b0\u6dfb\u52a0README\u65f6\u7684\u63d0\u4ea4\u3002\u901a\u8fc7git show HEAD\u53ef\u4ee5\u67e5\u770b\u6700\u65b0\u63d0\u4ea4\u7684\u5185\u5bb9\u3002<\/p>\n<pre class=\"post-pre\"><code>$ git show HEAD\r\ncommit 7022b44cb174e7d1d932a950d052fcdec9b36408 (HEAD -&gt; master, origin\/master)\r\nAuthor: hoge &lt;53826023+hoge@users.noreply.github.com&gt;\r\nDate:   Sat Oct 12 22:15:23 2019 +0900\r\n\r\n    Create README.md\r\n\r\ndiff --git a\/README.md b\/README.md\r\nnew file mode 100644\r\nindex 0000000..bab6eaf\r\n--- \/dev\/null\r\n+++ b\/README.md\r\n@@ -0,0 +1,2 @@\r\n+# sample\r\n+sample for remote repository\r\n\r\n<\/code><\/pre>\n<p>\u987a\u4fbf\u8bf4\u4e00\u4e0b\uff0c\u6700\u65b0\u63d0\u4ea4\u7684\u524d\u4e00\u6b21\u63d0\u4ea4\u88ab\u79f0\u4e3aHEAD^\u3002<br \/>\n\u6bcf\u589e\u52a0\u4e00\u4e2a^\uff0c\u8868\u793a\u5f80\u524d\u4e00\u4e2a\u63d0\u4ea4\u3002<\/p>\n<p>\u6700\u65b0\u63d0\u4ea4\u7684\u524d\u4e00\u4e2a\u63d0\u4ea4\u4f1a\u6210\u4e3a\u7b2c\u4e00\u4e2a\u63d0\u4ea4\u3002<\/p>\n<pre class=\"post-pre\"><code>$ git show HEAD^\r\ncommit f733bfe11003832f28f4803481cbe086e1903e4a\r\nAuthor: hoge &lt;hoge@gmail.com&gt;\r\nDate:   Sat Oct 12 19:13:31 2019 +0900\r\n\r\n    first commit\r\n\r\ndiff --git a\/test1 b\/test1\r\nnew file mode 100644\r\nindex 0000000..e69de29\r\n<\/code><\/pre>\n<p>\u6362\u53e5\u8bdd\u8bf4\uff0cgit reset HEAD test2\u5c06\u4f7f\u5f97HEAD\u56de\u5230\u521d\u59cb\u72b6\u6001\u3002<br \/>\n\u5728commit\u540e\u9762\u7684f733bfe11003832f28f4803481cbe086e1903e4a\u662f\u4e00\u4e2a\u63d0\u4ea4ID\uff0c\u7528\u5b83\u66ff\u4ee3HEAD\u8f93\u5165\u540c\u6837\u6548\u679c\u3002<\/p>\n<h2>\u4fee\u6539\u63d0\u4ea4\u65f6\u7684\u8bc4\u8bba<\/h2>\n<p>\u5982\u679c\u60a8\u60f3\u8981\u4fee\u6539\u6700\u65b0\u63d0\u4ea4\u7684\u6ce8\u91ca\u3002<\/p>\n<p>\u9996\u5148\uff0c\u5c06\u6587\u4ef6\u201ctest2\u201d\u6dfb\u52a0\u5230\u6682\u5b58\u533a\uff0c\u5e76\u8fdb\u884c\u63d0\u4ea4\u3002\u6ce8\u91ca\u5c06\u88ab\u8bbe\u4e3a\u201c\u6dfb\u52a0hoge\u201d\u3002<\/p>\n<pre class=\"post-pre\"><code>$ git add test2\r\n$ git commit -m \"add hoge\"\r\n[master c26d97e] add hoge\r\n 1 file changed, 0 insertions(+), 0 deletions(-)\r\n create mode 100644 test2\r\n<\/code><\/pre>\n<p>\u4f7f\u7528git log\u547d\u4ee4\u6765\u786e\u8ba4\u5df2\u63d0\u4ea4\u7684\u4e8b\u9879\u3002<\/p>\n<pre class=\"post-pre\"><code>$ git log\r\ncommit c26d97e9a6c9460a0b9790f3040b12beca1750f0 (HEAD -&gt; master)\r\nAuthor: hoge &lt;hoge@gmail.com&gt;\r\nDate:   Sun Oct 13 15:11:59 2019 +0900\r\n\r\n    add hoge\r\n<\/code><\/pre>\n<p>\u6211\u5c06\u628a\u8bc4\u8bba\u4fee\u6539\u4e3a\u201c\u6dfb\u52a0\u6d4b\u8bd52\u201d\u3002<\/p>\n<pre class=\"post-pre\"><code>$ git commit --amend -m \"add test2\"\r\n<\/code><\/pre>\n<p>\u8ba9\u6211\u4eec\u786e\u4fdd\u5df2\u7ecf\u5bf9\u63d0\u4ea4\u65e5\u5fd7\u7684\u6ce8\u91ca\u8fdb\u884c\u4e86\u4fee\u6b63\u3002<\/p>\n<pre class=\"post-pre\"><code>$ git log\r\ncommit 255795fc007dc6c5e64cc4acd2a54ca1e62f64c4 (HEAD -&gt; master)\r\nAuthor: hoge &lt;hoge@gmail.com&gt;\r\nDate:   Sun Oct 13 15:11:59 2019 +0900\r\n\r\n    add test2\r\n<\/code><\/pre>\n<p>\u8bc4\u8bba\u5df2\u7ecf\u88ab\u4fee\u6b63\u4e86\u3002<\/p>\n<h2>\u64a4\u9500\u63d0\u4ea4<\/h2>\n<p>\u6211\u4e0d\u5c0f\u5fc3\u63d0\u4ea4\u4e86\u9519\u8bef\u7684\u5185\u5bb9\uff0c\u4f46\u662f\u5f53\u6709\u4e00\u4e9b\u4fee\u6539\u9057\u6f0f\u65f6\uff0c\u60f3\u8981\u53d6\u6d88\u63d0\u4ea4\u7684\u60c5\u51b5\u4e0b\u4f7f\u7528\u3002<\/p>\n<p>\u8fd9\u4e2a\u4e5f\u53ef\u4ee5\u4f7f\u7528git reset\u3002<\/p>\n<pre class=\"post-pre\"><code>$ git reset --soft HEAD^\r\n<\/code><\/pre>\n<p>\u5728Git\u4e2d\uff0cHEAD\u6307\u7684\u662f\u6700\u65b0\u63d0\u4ea4\u7684\u524d\u4e00\u4e2a\u63d0\u4ea4\uff0c\u56e0\u6b64\u5012\u56de\u5230\u6700\u65b0\u63d0\u4ea4\u7684\u524d\u4e00\u4e2a\u63d0\u4ea4\u610f\u5473\u7740\u56de\u5230\u6700\u65b0\u63d0\u4ea4\u7684\u524d\u4e00\u4e2a\u72b6\u6001\u3002\u5982\u679c\u52a0\u4e0a&#8211;soft\u9009\u9879\uff0c\u90a3\u4e48\u53ea\u4f1a\u64a4\u6d88\u63d0\u4ea4\u64cd\u4f5c\uff0c\u5e76\u56de\u5230\u88ab\u6682\u5b58\u7684\u72b6\u6001\u3002<\/p>\n<p>\u8ba9\u6211\u4eec\u6765\u67e5\u770b\u63d0\u4ea4\u8bb0\u5f55\u5427\u3002<br \/>\n\u521a\u624d\u7684\u201cadd test2\u201d\u7684\u63d0\u4ea4\u5df2\u7ecf\u6d88\u5931\u4e86\uff0c\u5bf9\u5427\u3002<\/p>\n<pre class=\"post-pre\"><code>$ git log\r\ncommit 7022b44cb174e7d1d932a950d052fcdec9b36408 (HEAD -&gt; master, origin\/master)\r\nAuthor: hoge &lt;53826023+hoge@users.noreply.github.com&gt;\r\nDate:   Sat Oct 12 22:15:23 2019 +0900\r\n\r\n    Create README.md\r\n\r\ncommit f733bfe11003832f28f4803481cbe086e1903e4a\r\nAuthor: hoge &lt;hoge@gmail.com&gt;\r\nDate:   Sat Oct 12 19:13:31 2019 +0900\r\n\r\n    first commit\r\n<\/code><\/pre>\n<p>\u8ba9\u6211\u4eec\u901a\u8fc7git status\u67e5\u770b\u6682\u5b58\u7684\u72b6\u6001\u3002\u770b\u8d77\u6765test2\u6587\u4ef6\u5df2\u7ecf\u88ab\u6dfb\u52a0\u4e86\u3002<\/p>\n<pre class=\"post-pre\"><code>$ git status\r\nOn branch master\r\nChanges to be committed:\r\n  (use \"git reset HEAD &lt;file&gt;...\" to unstage)\r\n\r\n    new file:   test2\r\n<\/code><\/pre>\n<p>\u503c\u5f97\u4e00\u63d0\u7684\u662f\uff0c\u5982\u679c\u6ca1\u6709\u4f7f\u7528&#8211;soft\u9009\u9879\uff0c\u6dfb\u52a0\u5230\u6682\u5b58\u533a\u7684\u64cd\u4f5c\u5c06\u4e00\u5e76\u53d6\u6d88\u3002<br \/>\n\u53e6\u5916\uff0c\u5982\u679c\u4f7f\u7528&#8211;hard\u9009\u9879\uff0c\u5de5\u4f5c\u4e2d\u7684\u6587\u4ef6\u72b6\u6001\u4e5f\u5c06\u53d8\u4e3aHEAD^\u7684\u72b6\u6001\uff08\u6700\u65b0\u63d0\u4ea4\u7684\u524d\u4e00\u4e2a\u72b6\u6001\uff09\u3002\u4e5f\u5c31\u662f\u8bf4\uff0ctest2\u6587\u4ef6\u5c06\u88ab\u5220\u9664\u3002\uff08\u8bf7\u5c0f\u5fc3\u3002\u3002\uff09<\/p>\n<h2>\u6062\u590d\u88ab\u63a8\u9001\u7684\u6587\u4ef6<\/h2>\n<p>\u5f53\u4e0d\u5c0f\u5fc3\u70b9\u51fb\u4e86Push\u6309\u94ae\u7684\u65f6\u5019\uff0c\u53ef\u4ee5\u53d6\u6d88\u8fd9\u4e2aPush\u3002<br \/>\n\u5982\u679c\u591a\u4eba\u5728\u8fdb\u884c\u4f7f\u7528\u540c\u4e00\u4e2a\u8fdc\u7a0b\u4ee3\u7801\u5e93\u8fdb\u884c\u5de5\u4f5c\u7684\u8bdd\uff0c\u8fd9\u79cd\u64cd\u4f5c\u6709\u4e9b\u5371\u9669\u3002\u6211\u4eec\u9700\u8981\u786e\u4fdd\u5927\u5bb6\u77e5\u9053\u5982\u4f55\u6b63\u786e\u53d6\u6d88Push\u3002<\/p>\n<h3>\u5047\u88dd\u4ec0\u9ebc\u90fd\u6c92\u767c\u751f<\/h3>\n<p>\u9996\u5148\uff0c\u5c06\u6587\u4ef6\u201ctest2\u201d\u63d0\u4ea4\u5e76\u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93\u4e2d\u3002<\/p>\n<pre class=\"post-pre\"><code>$ git commit -m \"add test2\"\r\n[master 72225df] add test2\r\n 1 file changed, 0 insertions(+), 0 deletions(-)\r\n create mode 100644 test2\r\n\r\n$ git push origin master\r\nEnumerating objects: 3, done.\r\nCounting objects: 100% (3\/3), done.\r\nDelta compression using up to 4 threads\r\nCompressing objects: 100% (2\/2), done.\r\nWriting objects: 100% (2\/2), 264 bytes | 264.00 KiB\/s, done.\r\nTotal 2 (delta 0), reused 0 (delta 0)\r\nTo https:\/\/github.com\/hoge\/sample.git\r\n   7022b44..72225df  master -&gt; master\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d2e1f37434c4406c53638\/47-0.png\" alt=\"sample_for_remote_repository.png\" \/><\/div>\n<p>\u770b\u8d77\u6765\u4e5f\u6dfb\u52a0\u4e86\u63d0\u4ea4\u65e5\u5fd7\u5462\u3002<\/p>\n<pre class=\"post-pre\"><code>$ git log\r\ncommit 72225dfff26c3e09114614739f584b5b6c9701af (HEAD -&gt; master, origin\/master)\r\nAuthor: hoge &lt;hoge@gmail.com&gt;\r\nDate:   Sun Oct 13 16:54:55 2019 +0900\r\n\r\n    add test2\r\n\r\ncommit 7022b44cb174e7d1d932a950d052fcdec9b36408\r\nAuthor: hoge &lt;53826023+hoge@users.noreply.github.com&gt;\r\nDate:   Sat Oct 12 22:15:23 2019 +0900\r\n\r\n    Create README.md\r\n\r\ncommit f733bfe11003832f28f4803481cbe086e1903e4a\r\nAuthor: hoge &lt;hoge@gmail.com&gt;\r\nDate:   Sat Oct 12 19:13:31 2019 +0900\r\n\r\n    first commit\r\n<\/code><\/pre>\n<p>\u9996\u5148\uff0c\u6309\u7167\u4e4b\u524d\u6240\u8ff0\u7684\u65b9\u6cd5\u53d6\u6d88\u63d0\u4ea4\u3002<\/p>\n<pre class=\"post-pre\"><code>$ git reset --soft HEAD^\r\n$ git log\r\ncommit 7022b44cb174e7d1d932a950d052fcdec9b36408 (HEAD -&gt; master)\r\nAuthor: hoge &lt;53826023+hoge@users.noreply.github.com&gt;\r\nDate:   Sat Oct 12 22:15:23 2019 +0900\r\n\r\n    Create README.md\r\n\r\ncommit f733bfe11003832f28f4803481cbe086e1903e4a\r\nAuthor: hoge &lt;hoge@gmail.com&gt;\r\nDate:   Sat Oct 12 19:13:31 2019 +0900\r\n\r\n    first commit\r\n<\/code><\/pre>\n<p>\u6d4b\u8bd52\u7684\u63d0\u4ea4\u6d88\u5931\u4e86\uff0c\u662f\u5417\uff1f<\/p>\n<p>\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u91cd\u65b0\u63d0\u4ea4(push)\u3002<\/p>\n<pre class=\"post-pre\"><code>$ git push origin mastser\r\nerror: src refspec mastser does not match any.\r\nerror: failed to push some refs to 'https:\/\/github.com\/hoge\/sample.git'\r\n<\/code><\/pre>\n<p>\u54ce\u5440\uff0c\u51fa\u9519\u4e86\u3002<br \/>\n\u662f\u56e0\u4e3a\u8fdc\u7a0b\u4ed3\u5e93\u4e2d\u8bb0\u5f55\u7684\u63d0\u4ea4\u65e5\u5fd7\u4e0e\u63a8\u9001\u7684\u63d0\u4ea4\u65e5\u5fd7\u4e0d\u4e00\u81f4\u3002<br \/>\n\u5177\u4f53\u6765\u8bf4\uff0c\u8fdc\u7a0b\u4ed3\u5e93\u4e2d\u4ecd\u7136\u5b58\u5728\u7740\u201cadd test2\u201d\u7684\u65e5\u5fd7\uff0c\u4f46\u662f\u65b0\u63a8\u9001\u7684\u63d0\u4ea4\u65e5\u5fd7\u4e2d\u5374\u4e0d\u518d\u5305\u542b\u201cadd test2\u201d\u3002<\/p>\n<p>\u867d\u7136\u4e0d\u592a\u793c\u8c8c\uff0c\u4f46\u6211\u4eec\u4f1a\u4f7f\u7528 -f \u8fdb\u884c\u5f3a\u5236\u63a8\u9001\u3002<\/p>\n<pre class=\"post-pre\"><code>$ git push -f origin master\r\nTotal 0 (delta 0), reused 0 (delta 0)\r\nTo https:\/\/github.com\/hoge\/sample.git\r\n + 72225df...7022b44 master -&gt; master (forced update)\r\n<\/code><\/pre>\n<p>\u6ca1\u6709\u51fa\u73b0\u9519\u8bef\uff0c\u53ef\u4ee5\u8fdb\u884c\u63a8\u9001\u4e86\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d2e1f37434c4406c53638\/59-0.png\" alt=\"sample_for_remote_repository2.png\" \/><\/div>\n<h2>\u89e3\u51b3\u51b2\u7a81<\/h2>\n<p>\u5982\u679c\u8fdc\u7a0b\u4ed3\u5e93\u548c\u672c\u5730\u4ed3\u5e93\u5728\u540c\u4e00\u4e2a\u5730\u65b9\u6709\u66f4\u65b0\u7684\u60c5\u51b5\u4e0b\uff0c\u5f53\u4ece\u672c\u5730\u4ed3\u5e93\u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93\u65f6\u4f1a\u51fa\u73b0\u9519\u8bef\uff0c\u65e0\u6cd5\u63a8\u9001\u3002\u8fd9\u79cd\u60c5\u51b5\u88ab\u79f0\u4e3a\u51b2\u7a81\u3002\u5982\u679c\u6709\u591a\u4eba\u540c\u65f6\u66f4\u65b0\u540c\u4e00\u4e2a\u8fdc\u7a0b\u4ed3\u5e93\uff0c\u4e5f\u6709\u53ef\u80fd\u53d1\u751f\u8fd9\u79cd\u60c5\u51b5\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d2e1f37434c4406c53638\/62-0.png\" alt=\"sample_for_remote_repository3.png\" \/><\/div>\n<p>\u63a5\u4e0b\u6765\uff0c\u5728\u672c\u5730\u4ed3\u5e93\u4e2d\u4e5f\u8981\u4fee\u6539README\u7684\u5185\u5bb9\u3002<br \/>\n\u4f7f\u7528vi\u547d\u4ee4\uff0c\u5220\u9664README\u4e2d\u7684\u6240\u6709\u5185\u5bb9\uff0c\u5e76\u8f93\u5165&#8221;test&#8221;\u3002<\/p>\n<p>\u7136\u540e\uff0c\u5c06\u5176\u6dfb\u52a0\u5230\u6682\u5b58\u533a\uff0c\u5e76\u5c1d\u8bd5\u4e00\u6b21\u6027\u6267\u884c\u63d0\u4ea4\u548c\u63a8\u9001\u64cd\u4f5c\u3002<\/p>\n<pre class=\"post-pre\"><code>$ vi README.md\r\n$ git add README.md\r\n$ git commit -m \"mod README\"\r\n$ git push origin master\r\nTo https:\/\/github.com\/maru-e\/sample.git\r\n ! [rejected]        master -&gt; master (fetch first)\r\nerror: failed to push some refs to 'https:\/\/github.com\/hoge\/sample.git'\r\nhint: Updates were rejected because the remote contains work that you do\r\nhint: not have locally. This is usually caused by another repository pushing\r\nhint: to the same ref. You may want to first integrate the remote changes\r\nhint: (e.g., 'git pull ...') before pushing again.\r\nhint: See the 'Note about fast-forwards' in 'git push --help' for details.\r\n<\/code><\/pre>\n<p>\u5f53\u60a8\u63d0\u4ea4\u65f6\u51fa\u73b0\u4e86\u9519\u8bef\u3002<br \/>\n\u662f\u7531\u4e8e\u8fdc\u7a0b\u4ed3\u5e93\u7684\u66f4\u6539\u4e0e\u672c\u5730\u4ed3\u5e93\u7684\u66f4\u6539\u51b2\u7a81\uff0c\u56e0\u6b64\u4e0d\u77e5\u9053\u5e94\u8be5\u4f18\u5148\u91c7\u7528\u54ea\u4e00\u4e2a\u3002<\/p>\n<p>\u5f53\u9047\u5230\u8fd9\u79cd\u60c5\u51b5\u65f6\uff0c\u4f60\u4f1a\u60f3\u77e5\u9053\u8fdc\u7a0b\u4ed3\u5e93\u53d1\u751f\u4e86\u4ec0\u4e48\u6837\u7684\u66f4\u6539\uff0c\u5bf9\u5417\uff1f<br \/>\n\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528git fetch\u5c06\u8fdc\u7a0b\u4ed3\u5e93\u7684\u66f4\u6539\u5185\u5bb9\u83b7\u53d6\u5230\u672c\u5730\u4ed3\u5e93\u4e2d\u3002<\/p>\n<pre class=\"post-pre\"><code>$ git fetch\r\nremote: Enumerating objects: 5, done.\r\nremote: Counting objects: 100% (5\/5), done.\r\nremote: Compressing objects: 100% (2\/2), done.\r\nremote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0\r\nUnpacking objects: 100% (3\/3), done.\r\nFrom https:\/\/github.com\/hoge\/sample\r\n   7022b44..7beb0cd  master     -&gt; origin\/master\r\n<\/code><\/pre>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u68c0\u67e5\u672c\u5730\u4ed3\u5e93\u7684\u4e3b\u5206\u652f\uff08master\uff09\u6700\u65b0\u7684\u63d0\u4ea4\uff08HEAD\uff09\u4e0e\u8fdc\u7a0b\u4ed3\u5e93\uff08origin\uff09\u7684\u4e3b\u5206\u652f\u4e4b\u95f4\u7684\u5dee\u5f02\u3002<\/p>\n<pre class=\"post-pre\"><code>$ git diff HEAD origin\/master\r\ndiff --git a\/README.md b\/README.md\r\nindex 9daeafb..a099415 100644\r\n--- a\/README.md\r\n+++ b\/README.md\r\n@@ -1 +1 @@\r\n-test\r\n+modify comment\r\n<\/code><\/pre>\n<p>\u53ef\u4ee5\u770b\u5230README.md\u6587\u4ef6\u5df2\u88ab\u4fee\u6539\uff0c\u672c\u5730\u4ee3\u7801\u5e93\u4e2d\u6587\u4ef6\u5185\u5bb9\u4e3a&#8221;test&#8221;\uff0c\u8fdc\u7a0b\u4ee3\u7801\u5e93\u4e2d\u6587\u4ef6\u5185\u5bb9\u4e3a&#8221;modify comment&#8221;\u3002<\/p>\n<p>\u5982\u679c\u53ef\u4ee5\u8986\u76d6\u8fdc\u7a0b\u4ed3\u5e93\u7684\u5185\u5bb9\uff0c\u8bf7\u4f7f\u7528git push -f origin master\u6765\u5f3a\u5236\u63a8\u9001\u672c\u5730\u4ed3\u5e93\u7684\u5185\u5bb9\u81f3\u8fdc\u7a0b\u4ed3\u5e93\u3002<\/p>\n<p>\u5982\u679c\u60a8\u60f3\u8981\u8986\u76d6\u672c\u5730\u5b58\u50a8\u5e93\u4e2d\u7684\u8fdc\u7a0b\u5b58\u50a8\u5e93\u5185\u5bb9\uff0c\u53ef\u4ee5\u4f7f\u7528git pull origin master\u8fdb\u884c\u8986\u76d6\u3002<\/p>\n<p>\u901a\u8fc7\u68c0\u67e5\u5dee\u5f02\uff0c\u9009\u62e9\u5176\u4e2d\u4e00\u79cd\u65b9\u6cd5\u6765\u4fee\u6b63\u5185\u5bb9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e4b\u524d\u7684\u6587\u7ae0\u5728\u9019\u88e1\u3002 Git\u548cGitHub\u5165\u95e8\uff081\/3\uff09 Git\u548cGitHub\u5165\u95e8\uff082\/3\uff09 \u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\u5e94\u8be5\u600e [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-37358","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\u548cGitHub\u5165\u95e8\uff083\/3\uff09 - 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\u548cgithub\u5165\u95e8\uff083-3\uff09\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Git\u548cGitHub\u5165\u95e8\uff083\/3\uff09\" \/>\n<meta property=\"og:description\" content=\"\u4e4b\u524d\u7684\u6587\u7ae0\u5728\u9019\u88e1\u3002 Git\u548cGitHub\u5165\u95e8\uff081\/3\uff09 Git\u548cGitHub\u5165\u95e8\uff082\/3\uff09 \u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\u5e94\u8be5\u600e [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/git\u548cgithub\u5165\u95e8\uff083-3\uff09\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-24T06:58:58+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-05-03T20:16:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d2e1f37434c4406c53638\/47-0.png\" \/>\n<meta name=\"author\" content=\"\u6e05, \u626c\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u6e05, \u626c\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \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%92%8cgithub%e5%85%a5%e9%97%a8%ef%bc%883-3%ef%bc%89\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/git%e5%92%8cgithub%e5%85%a5%e9%97%a8%ef%bc%883-3%ef%bc%89\/\",\"name\":\"Git\u548cGitHub\u5165\u95e8\uff083\/3\uff09 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-07-24T06:58:58+00:00\",\"dateModified\":\"2024-05-03T20:16:44+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/cb5556d2501da73d864cac945e8d9461\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/git%e5%92%8cgithub%e5%85%a5%e9%97%a8%ef%bc%883-3%ef%bc%89\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/git%e5%92%8cgithub%e5%85%a5%e9%97%a8%ef%bc%883-3%ef%bc%89\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/git%e5%92%8cgithub%e5%85%a5%e9%97%a8%ef%bc%883-3%ef%bc%89\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Git\u548cGitHub\u5165\u95e8\uff083\/3\uff09\"}]},{\"@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\/cb5556d2501da73d864cac945e8d9461\",\"name\":\"\u6e05, \u626c\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/32a4239de8ff29adace466261d309424a1e5fe9f7e3036bf89fe03f2e3dbe717?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/32a4239de8ff29adace466261d309424a1e5fe9f7e3036bf89fe03f2e3dbe717?s=96&d=mm&r=g\",\"caption\":\"\u6e05, \u626c\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/qingyang\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/git%e5%92%8cgithub%e5%85%a5%e9%97%a8%ef%bc%883-3%ef%bc%89\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Git\u548cGitHub\u5165\u95e8\uff083\/3\uff09 - 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\u548cgithub\u5165\u95e8\uff083-3\uff09\/","og_locale":"zh_CN","og_type":"article","og_title":"Git\u548cGitHub\u5165\u95e8\uff083\/3\uff09","og_description":"\u4e4b\u524d\u7684\u6587\u7ae0\u5728\u9019\u88e1\u3002 Git\u548cGitHub\u5165\u95e8\uff081\/3\uff09 Git\u548cGitHub\u5165\u95e8\uff082\/3\uff09 \u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\u5e94\u8be5\u600e [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/git\u548cgithub\u5165\u95e8\uff083-3\uff09\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-07-24T06:58:58+00:00","article_modified_time":"2024-05-03T20:16:44+00:00","og_image":[{"url":"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d2e1f37434c4406c53638\/47-0.png"}],"author":"\u6e05, \u626c","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u6e05, \u626c","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/git%e5%92%8cgithub%e5%85%a5%e9%97%a8%ef%bc%883-3%ef%bc%89\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/git%e5%92%8cgithub%e5%85%a5%e9%97%a8%ef%bc%883-3%ef%bc%89\/","name":"Git\u548cGitHub\u5165\u95e8\uff083\/3\uff09 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-07-24T06:58:58+00:00","dateModified":"2024-05-03T20:16:44+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/cb5556d2501da73d864cac945e8d9461"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/git%e5%92%8cgithub%e5%85%a5%e9%97%a8%ef%bc%883-3%ef%bc%89\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/git%e5%92%8cgithub%e5%85%a5%e9%97%a8%ef%bc%883-3%ef%bc%89\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/git%e5%92%8cgithub%e5%85%a5%e9%97%a8%ef%bc%883-3%ef%bc%89\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"Git\u548cGitHub\u5165\u95e8\uff083\/3\uff09"}]},{"@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\/cb5556d2501da73d864cac945e8d9461","name":"\u6e05, \u626c","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/32a4239de8ff29adace466261d309424a1e5fe9f7e3036bf89fe03f2e3dbe717?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/32a4239de8ff29adace466261d309424a1e5fe9f7e3036bf89fe03f2e3dbe717?s=96&d=mm&r=g","caption":"\u6e05, \u626c"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/qingyang\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/git%e5%92%8cgithub%e5%85%a5%e9%97%a8%ef%bc%883-3%ef%bc%89\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/37358","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\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=37358"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/37358\/revisions"}],"predecessor-version":[{"id":96062,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/37358\/revisions\/96062"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=37358"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=37358"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=37358"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}