{"id":67,"date":"2026-05-07T08:25:24","date_gmt":"2026-05-07T00:25:24","guid":{"rendered":"http:\/\/49.232.244.149\/?p=67"},"modified":"2026-05-08T22:20:02","modified_gmt":"2026-05-08T14:20:02","slug":"git%e4%bd%bf%e7%94%a8%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"https:\/\/www.everfades.cn\/index.php\/2026\/05\/07\/git%e4%bd%bf%e7%94%a8%e6%8c%87%e5%8d%97\/","title":{"rendered":"Git\u4f7f\u7528\u6307\u5357"},"content":{"rendered":"<h4>2026.5.6\u2014\u2014by Everfades<\/h4>\n<p>\u5982\u679c\u60a8\u6709\u5b9d\u8d35\u7684\u610f\u89c1\u6216\u5efa\u8bae\uff0c\u8bf7\u53d1\u90ae\u4ef6\u81f3:everfades1218@gmail.com\u6216everfades@foxmail.com<\/p>\n<p><strong>\u5728\u4f7f\u7528Typora\u9605\u8bfb\u524d\uff0c\u8bf7\u5c06\u6587\u4ef6\u2192\u504f\u597d\u8bbe\u7f6e\u2192Markdown\u2192\u5185\u8054\u516c\u5f0f \u52fe\u9009\u4e0a\uff0c\u4ee5\u514d\u663e\u793a\u51fa\u9519\uff01<\/strong><\/p>\n<h2>\u4e00\u3001\u57fa\u7840\u914d\u7f6e\u4e0e\u4fe1\u606f<\/h2>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: center;\">\u547d\u4ee4<\/th>\n<th style=\"text-align: center;\">\u7528\u9014<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: center;\">git config &#8211;global user.name &#8220;\u59d3\u540d&#8221;<\/td>\n<td style=\"text-align: center;\">\u8bbe\u7f6e\u7528\u6237\u540d<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">git config &#8211;global user.email &#8220;\u90ae\u7bb1&#8221;<\/td>\n<td style=\"text-align: center;\">\u8bbe\u7f6e\u90ae\u7bb1<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">git config &#8211;list<\/td>\n<td style=\"text-align: center;\">\u67e5\u770b\u6240\u6709\u914d\u7f6e<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">git init<\/td>\n<td style=\"text-align: center;\">\u521d\u59cb\u5316\u65b0\u4ed3\u5e93<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">git clone<\/td>\n<td style=\"text-align: center;\">\u514b\u9686\u8fdc\u7a0b\u4ed3\u5e93<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">git status<\/td>\n<td style=\"text-align: center;\">\u67e5\u770b\u5de5\u4f5c\u533a\u72b6\u6001<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">git log \/ git log &#8211;oneline &#8211;graph<\/td>\n<td style=\"text-align: center;\">\u67e5\u770b\u63d0\u4ea4\u5386\u53f2<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h2>\u4e8c\u3001\u6682\u5b58\u4e0e\u63d0\u4ea4<\/h2>\n<ul>\n<li><strong>git add # \u6682\u5b58\u6307\u5b9a\u6587\u4ef6<\/strong><\/li>\n<li><strong>git add . # \u6682\u5b58\u6240\u6709\u4fee\u6539<\/strong><\/li>\n<li><strong>git add -p # \u4ea4\u4e92\u5f0f\u9009\u62e9\u6682\u5b58\uff08\u6309\u5757\u786e\u8ba4\uff09<\/strong><\/li>\n<li><strong>git commit -m &#8220;msg&#8221; # \u63d0\u4ea4<\/strong><\/li>\n<li><strong>git commit &#8211;amend # \u4fee\u6539\u6700\u8fd1\u4e00\u6b21\u63d0\u4ea4\uff08\u4e0d\u8981 amend \u5df2 push \u7684\uff09<\/strong><\/li>\n<li><strong>git reset HEAD # \u53d6\u6d88\u6682\u5b58<\/strong><\/li>\n<li><strong>git checkout &#8212; # \u4e22\u5f03\u5de5\u4f5c\u533a\u4fee\u6539\uff08\u4e0d\u53ef\u6062\u590d\uff09<\/strong><\/li>\n<li><strong>git restore # \u65b0\u7248\uff1a\u4e22\u5f03\u5de5\u4f5c\u533a\u4fee\u6539<\/strong><\/li>\n<li><strong>git restore &#8211;staged # \u65b0\u7248\uff1a\u53d6\u6d88\u6682\u5b58<\/strong><\/li>\n<\/ul>\n<hr \/>\n<h2><\/h2>\n<h2>\u4e09\u3001\u5206\u652f\u64cd\u4f5c<\/h2>\n<ul>\n<li><strong>git branch # \u5217\u51fa\u672c\u5730\u5206\u652f<\/strong><\/li>\n<li><strong>git branch -a # \u5217\u51fa\u6240\u6709\u5206\u652f\uff08\u542b\u8fdc\u7a0b\uff09<\/strong><\/li>\n<li><strong>git branch # \u521b\u5efa\u5206\u652f<\/strong><\/li>\n<li><strong>git branch -d # \u5220\u9664\u5206\u652f\uff08\u5df2\u5408\u5e76\uff09<\/strong><\/li>\n<li><strong>git branch -D # \u5f3a\u5236\u5220\u9664\u5206\u652f<\/strong><\/li>\n<li><strong>git switch # \u5207\u6362\u5206\u652f\uff08\u65b0\u7248\uff09<\/strong><\/li>\n<li><strong>git checkout # \u5207\u6362\u5206\u652f\uff08\u65e7\u7248\uff09<\/strong><\/li>\n<li><strong>git switch -c # \u521b\u5efa\u5e76\u5207\u6362<\/strong><\/li>\n<li><strong>git checkout -b # \u540c\u4e0a\uff08\u65e7\u7248\uff09<\/strong><\/li>\n<li><strong>git merge # \u5408\u5e76\u6307\u5b9a\u5206\u652f\u5230\u5f53\u524d\u5206\u652f<\/strong><\/li>\n<li><strong>git rebase # \u53d8\u57fa\u5230\u6307\u5b9a\u5206\u652f<\/strong><\/li>\n<li><strong>git cherry-pick # \u6311\u9009\u67d0\u6b21\u63d0\u4ea4\u5e94\u7528\u5230\u5f53\u524d\u5206\u652f<\/strong><\/li>\n<\/ul>\n<hr \/>\n<h2>\u56db\u3001\u8fdc\u7a0b\u534f\u4f5c<\/h2>\n<ul>\n<li><strong>git remote -v # \u67e5\u770b\u8fdc\u7a0b\u4ed3\u5e93<\/strong><\/li>\n<li><strong>git remote add # \u6dfb\u52a0\u8fdc\u7a0b\u4ed3\u5e93<\/strong><\/li>\n<li><strong>git fetch # \u62c9\u53d6\u8fdc\u7a0b\u66f4\u65b0\uff08\u4e0d\u5408\u5e76\uff09<\/strong><\/li>\n<li><strong>git pull # fetch + merge<\/strong><\/li>\n<li><strong>git pull &#8211;rebase # fetch + rebase\uff08\u63a8\u8350\uff09<\/strong><\/li>\n<li><strong>git push origin # \u63a8\u9001\u5230\u8fdc\u7a0b<\/strong><\/li>\n<li><strong>git push -u origin # \u9996\u6b21\u63a8\u9001\u5e76\u5efa\u7acb\u8ffd\u8e2a<\/strong><\/li>\n<li><strong>git push &#8211;force-with-lease # \u5b89\u5168\u5f3a\u5236\u63a8\u9001<\/strong><\/li>\n<\/ul>\n<hr \/>\n<h2>\u4e94\u3001\u64a4\u9500\u4e0e\u56de\u9000<\/h2>\n<ul>\n<li><strong>git reset &#8211;soft HEAD~1 # \u64a4\u9500 commit\uff0c\u4fdd\u7559\u6682\u5b58\u533a\u548c\u5de5\u4f5c\u533a<\/strong><\/li>\n<li><strong>git reset &#8211;mixed HEAD~1 # \u64a4\u9500 commit \u548c\u6682\u5b58\uff0c\u4fdd\u7559\u5de5\u4f5c\u533a\uff08\u9ed8\u8ba4\uff09<\/strong><\/li>\n<li><strong>git reset &#8211;hard HEAD~1 # \u5168\u90e8\u64a4\u9500\uff08\u5371\u9669\uff01\u4e0d\u53ef\u6062\u590d\uff09<\/strong><\/li>\n<li><strong>git revert # \u5b89\u5168\u64a4\u9500\uff1a\u751f\u6210\u4e00\u4e2a\u65b0\u7684\u53cd\u5411\u63d0\u4ea4<\/strong><\/li>\n<li><strong>git stash # \u6682\u5b58\u5f53\u524d\u4fee\u6539<\/strong><\/li>\n<li><strong>git stash pop # \u6062\u590d\u6700\u8fd1\u4e00\u6b21 stash<\/strong><\/li>\n<li><strong>git stash list # \u67e5\u770b stash \u5217\u8868<\/strong><\/li>\n<\/ul>\n<hr \/>\n<h2>\u516d\u3001\u67e5\u770b\u5dee\u5f02\u4e0e\u5386\u53f2<\/h2>\n<ul>\n<li><strong>git diff # \u5de5\u4f5c\u533a vs \u6682\u5b58\u533a<\/strong><\/li>\n<li><strong>git diff &#8211;staged # \u6682\u5b58\u533a vs \u6700\u8fd1 commit<\/strong><\/li>\n<li><strong>git diff HEAD # \u5de5\u4f5c\u533a vs \u6700\u8fd1 commit<\/strong><\/li>\n<li><strong>git diff <\/strong><\/li>\n<li><strong>git show # \u67e5\u770b\u67d0\u6b21\u63d0\u4ea4\u7684\u8be6\u60c5<\/strong><\/li>\n<li><strong>git blame # \u67e5\u770b\u6bcf\u884c\u4ee3\u7801\u662f\u8c01\u5199\u7684<\/strong><\/li>\n<li><strong>git reflog # \u67e5\u770b HEAD \u79fb\u52a8\u5386\u53f2\uff08\u627e\u56de\u4e22\u5931\u7684 commit\uff09<\/strong><\/li>\n<\/ul>\n<hr \/>\n<h2>\u4e03\u3001\u9ad8\u7ea7\u6280\u5de7<\/h2>\n<p><strong>1.\u4ea4\u4e92\u5f0f\u53d8\u57fa\uff08\u5408\u5e76\/squash\/\u91cd\u6392 commit\uff09<\/strong><\/p>\n<ul>\n<li><strong>git rebase -i HEAD~3<\/strong><\/li>\n<\/ul>\n<p><strong>2.\u4e8c\u5206\u6cd5\u67e5\u627e\u5f15\u5165 bug \u7684\u63d0\u4ea4<\/strong><\/p>\n<ul>\n<li><strong>git bisect start<\/strong><\/li>\n<li><strong>git bisect bad<\/strong><\/li>\n<li><strong>git bisect good <\/strong><\/li>\n<\/ul>\n<p><strong>3<\/strong>.<strong>\u6e05\u7406\u672a\u8ddf\u8e2a\u7684\u6587\u4ef6\uff08\u5148 &#8211;dry-run \u9884\u89c8\uff09<\/strong><\/p>\n<ul>\n<li><strong>git clean -n # \u9884\u89c8<\/strong><\/li>\n<li><strong>git clean -f # \u5220\u9664<\/strong><\/li>\n<\/ul>\n<p><strong>4.\u6253\u6807\u7b7e<\/strong><\/p>\n<ul>\n<li><strong>git tag v1.0.0<\/strong><\/li>\n<li><strong>git tag -a v1.0.0 -m &#8220;\u63cf\u8ff0&#8221; # \u9644\u6ce8\u6807\u7b7e<\/strong><\/li>\n<li><strong>git push origin &#8211;tags<\/strong><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>2026.5.6\u2014\u2014by Everfades \u5982\u679c\u60a8\u6709\u5b9d\u8d35\u7684\u610f\u89c1\u6216\u5efa\u8bae\uff0c\u8bf7\u53d1\u90ae\u4ef6\u81f3:everfades1218 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[6,5],"class_list":["post-67","post","type-post","status-publish","format-standard","hentry","category-artical","tag-git","tag-github"],"_links":{"self":[{"href":"https:\/\/www.everfades.cn\/index.php\/wp-json\/wp\/v2\/posts\/67","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.everfades.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.everfades.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.everfades.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.everfades.cn\/index.php\/wp-json\/wp\/v2\/comments?post=67"}],"version-history":[{"count":1,"href":"https:\/\/www.everfades.cn\/index.php\/wp-json\/wp\/v2\/posts\/67\/revisions"}],"predecessor-version":[{"id":68,"href":"https:\/\/www.everfades.cn\/index.php\/wp-json\/wp\/v2\/posts\/67\/revisions\/68"}],"wp:attachment":[{"href":"https:\/\/www.everfades.cn\/index.php\/wp-json\/wp\/v2\/media?parent=67"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.everfades.cn\/index.php\/wp-json\/wp\/v2\/categories?post=67"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.everfades.cn\/index.php\/wp-json\/wp\/v2\/tags?post=67"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}