{"id":83252,"date":"2024-12-30T18:03:44","date_gmt":"2024-12-30T11:03:44","guid":{"rendered":"https:\/\/itviec.com\/blog\/?p=83252"},"modified":"2025-07-10T10:49:12","modified_gmt":"2025-07-10T03:49:12","slug":"git-reset-la-gi","status":"publish","type":"post","link":"https:\/\/itviec.com\/blog\/git-reset-la-gi\/","title":{"rendered":"Git Reset: H\u01b0\u1edbng d\u1eabn c\u00e1ch x\u00f3a commit b\u1eb1ng Git Reset"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">N\u1ed9i dung b\u00e0i vi\u1ebft<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/itviec.com\/blog\/git-reset-la-gi\/#Git_reset_la_gi\" >Git reset l\u00e0 g\u00ec?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/itviec.com\/blog\/git-reset-la-gi\/#Co_che_hoat_dong_cua_Git_reset\" >C\u01a1 ch\u1ebf ho\u1ea1t \u0111\u1ed9ng c\u1ee7a Git reset<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/itviec.com\/blog\/git-reset-la-gi\/#Cac_che_do_trong_git_reset\" >C\u00e1c ch\u1ebf \u0111\u1ed9 trong git reset<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/itviec.com\/blog\/git-reset-la-gi\/#Nhung_truong_hop_su_dung_va_luu_y_khi_dung_git_reset\" >Nh\u1eefng tr\u01b0\u1eddng h\u1ee3p s\u1eed d\u1ee5ng v\u00e0 l\u01b0u \u00fd khi d\u00f9ng git reset<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/itviec.com\/blog\/git-reset-la-gi\/#So_sanh_git_reset_va_git_revert\" >So s\u00e1nh git reset v\u00e0 git revert<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/itviec.com\/blog\/git-reset-la-gi\/#Cac_cau_hoi_thuong_gap_ve_Git_reset\" >C\u00e1c c\u00e2u h\u1ecfi th\u01b0\u1eddng g\u1eb7p v\u1ec1 Git reset<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/itviec.com\/blog\/git-reset-la-gi\/#Tong_ket\" >T\u1ed5ng k\u1ebft<\/a><\/li><\/ul><\/nav><\/div>\n\n<p><em><strong>Khi l\u00e0m vi\u1ec7c v\u1edbi Git, vi\u1ec7c t\u1ea1o ra c\u00e1c commit nh\u1eb1m l\u01b0u tr\u1eef l\u1ea1i c\u00e1c thay \u0111\u1ed5i \u0111\u00e3 th\u1ef1c hi\u1ec7n tr\u00ean m\u00e3 ngu\u1ed3n v\u00e0o kho l\u01b0u tr\u1eef Git. Tuy nhi\u00ean s\u1ebd c\u00f3 nh\u1eefng tr\u01b0\u1eddng h\u1ee3p m\u00e0 ch\u00fang ta c\u1ea7n h\u1ee7y b\u1ecf nh\u1eefng commit n\u00e0y, ch\u1eb3ng h\u1ea1n nh\u01b0 c\u00f3 l\u1ed7i trong c\u00e1c thay \u0111\u1ed5i, commit nh\u1ea7m t\u1eadp tin ho\u1eb7c t\u1ea1o commit nh\u1ea7m nh\u00e1nh. \u0110\u00e2y ch\u00ednh l\u00e0 l\u00fac Git Reset tr\u1edf th\u00e0nh c\u00f4ng c\u1ee5 c\u1ef1c k\u00ec h\u1eefu \u00edch. Nh\u01b0ng s\u1ee9c m\u1ea1nh c\u1ee7a Git reset c\u0169ng ti\u1ec1m \u1ea9n c\u00e1c r\u1ee7i ro n\u1ebfu kh\u00f4ng \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u00fang c\u00e1ch.<\/strong><\/em><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">\u0110\u1ecdc b\u00e0i vi\u1ebft n\u00e0y \u0111\u1ec3 hi\u1ec3u r\u00f5 h\u01a1n v\u1ec1:<\/span><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span style=\"font-weight: 400;\">Git reset l\u00e0 g\u00ec?<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">C\u01a1 ch\u1ebf ho\u1ea1t \u0111\u1ed9ng c\u1ee7a git reset<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">C\u00e1c ch\u1ebf \u0111\u1ed9 reset<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">Nh\u1eefng tr\u01b0\u1eddng h\u1ee3p s\u1eed d\u1ee5ng v\u00e0 l\u01b0u \u00fd khi d\u00f9ng git reset<\/span><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-git-reset-la-gi\"><span class=\"ez-toc-section\" id=\"Git_reset_la_gi\"><\/span><b>Git reset l\u00e0 g\u00ec?<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><span style=\"font-weight: 400;\">Tr\u01b0\u1edbc khi \u0111i v\u00e0o t\u00ecm hi\u1ec3u Git Reset, ch\u00fang ta s\u1ebd c\u00f9ng xem qua c\u00e1c tr\u1ea1ng th\u00e1i c\u1ee7a t\u1eadp tin trong Git v\u00e0 c\u00e1ch m\u00e0 Git qu\u1ea3n l\u00fd t\u1eadp tin trong m\u00e3 ngu\u1ed3n. Tr\u1ea1ng th\u00e1i c\u1ee7a c\u00e1c t\u1eadp tin trong m\u00e3 ngu\u1ed3n s\u1ebd \u0111\u01b0\u1ee3c Git qu\u1ea3n l\u00fd b\u1eb1ng ba th\u00e0nh ph\u1ea7n ch\u00ednh (th\u01b0\u1eddng \u0111\u01b0\u1ee3c g\u1ecdi l\u00e0 \u201cc\u1ea5u tr\u00fac 3 c\u00e2y\u201d) bao g\u1ed3m:<\/span><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><span style=\"font-weight: 400;\">Working Directory (Th\u01b0 m\u1ee5c l\u00e0m vi\u1ec7c): \u0110\u00e2y l\u00e0 n\u01a1i m\u00e0 l\u1eadp tr\u00ecnh vi\u00ean thao t\u00e1c, ch\u1ec9nh s\u1eeda c\u00e1c t\u1eadp tin trong m\u00e3 ngu\u1ed3n. N\u1ed9i dung c\u1ee7a c\u00e1c t\u1eadp tin trong khu v\u1ef1c n\u00e0y c\u00f3 th\u1ec3 \u1edf tr\u1ea1ng th\u00e1i \u0111\u00e3 thay \u0111\u1ed5i, nh\u01b0ng ch\u00fang v\u1eabn ch\u01b0a \u0111\u01b0\u1ee3c theo d\u00f5i b\u1edfi Git<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">Staging Area (V\u00f9ng t\u1ea1m\/ch\u1ec9 m\u1ee5c): \u0110\u00e2y l\u00e0 khu v\u1ef1c l\u01b0u tr\u1eef t\u1ea1m th\u1eddi c\u00e1c thay \u0111\u1ed5i c\u1ee7a t\u1eadp tin \u0111\u1ec3 chu\u1ea9n b\u1ecb commit. Khu v\u1ef1c n\u00e0y gi\u00fap l\u1eadp tr\u00ecnh vi\u00ean ki\u1ec3m so\u00e1t nh\u1eefng th\u00f4ng tin n\u00e0o s\u1ebd \u0111\u01b0\u1ee3c commit<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">Repository (Kho l\u01b0u tr\u1eef): N\u01a1i l\u01b0u tr\u1eef l\u1ecbch s\u1eed commit, c\u00e1c phi\u00ean b\u1ea3n c\u1ee7a m\u00e3 ngu\u1ed3n<\/span><\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"688\" height=\"202\" src=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-mo-hinh-3-cay-vippro.png\" alt=\"git m\u00f4 h\u00ecnh 3 c\u00e2y - itviec blog\" class=\"wp-image-83619\" srcset=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-mo-hinh-3-cay-vippro.png 688w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-mo-hinh-3-cay-vippro-300x88.png 300w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-mo-hinh-3-cay-vippro-640x188.png 640w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-mo-hinh-3-cay-vippro-200x59.png 200w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-mo-hinh-3-cay-vippro-100x29.png 100w\" sizes=\"auto, (max-width: 688px) 100vw, 688px\" \/><\/figure>\n\n\n\n<p><span style=\"font-weight: 400;\"><\/span><span style=\"font-weight: 400;\">Git Reset l\u00e0 m\u1ed9t c\u00f4ng c\u1ee5 r\u1ea5t linh ho\u1ea1t \u0111\u1ec3 th\u1ef1c hi\u1ec7n vi\u1ec7c ho\u00e0n t\u00e1c c\u00e1c thay \u0111\u1ed5i \u0111\u00e3 \u0111\u01b0\u1ee3c commit v\u00e0 l\u01b0u tr\u1eef trong repository. Git reset gi\u00fap lo\u1ea1i b\u1ecf c\u00e1c commit, \u0111\u01b0a nh\u1eefng thay \u0111\u1ed5i trong t\u1eadp tin tr\u1edf l\u1ea1i khu v\u1ef1c Staging ho\u1eb7c Khu v\u1ef1c l\u00e0m vi\u1ec7c, hay th\u1eadm ch\u00ed l\u00e0 x\u00f3a b\u1ecf d\u1eef li\u1ec7u thay \u0111\u1ed5i \u0111\u00f3.<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">C\u00fa ph\u00e1p c\u01a1 b\u1ea3n c\u1ee7a git reset:<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span style=\"font-weight: 400;\">git reset &#91;&lt;options&gt;] &#91;&lt;commit&gt;]<\/span><\/code><\/pre>\n\n\n\n<p><span style=\"font-weight: 400;\">Trong \u0111\u00f3:<\/span><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span style=\"font-weight: 400;\">options: l\u00e0 c\u00e1c t\u00f9y ch\u1ecdn ch\u1ebf \u0111\u1ed9 c\u1ee7a git reset, bao g\u1ed3m <code>--soft<\/code>, <code>--mixed<\/code>, <code>--hard<\/code>, <code>--merge<\/code>, <code>--keep<\/code><\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">commit: x\u00e1c \u0111\u1ecbnh commit m\u00e0 b\u1ea1n mu\u1ed1n di chuy\u1ec3n con tr\u1ecf HEAD \u0111\u1ebfn, c\u00f3 th\u1ec3 l\u00e0 <code>HEAD~&lt;s\u1ed1 commit><\/code> (s\u1ed1 commit t\u00ednh t\u1eeb commit m\u1edbi nh\u1ea5t), <code>commit_hash<\/code> (m\u00e3 b\u0103m c\u1ee7a m\u1ed9t commit), <code>branch_name<\/code> (m\u1ed9t nh\u00e1nh c\u1ee5 th\u1ec3)<\/span><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-c\u01a1-ch\u1ebf-ho\u1ea1t-d\u1ed9ng-c\u1ee7a-git-reset\"><span class=\"ez-toc-section\" id=\"Co_che_hoat_dong_cua_Git_reset\"><\/span><b>C\u01a1 ch\u1ebf ho\u1ea1t \u0111\u1ed9ng c\u1ee7a Git reset<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><span style=\"font-weight: 400;\">Git Reset l\u00e0 m\u1ed9t l\u1ec7nh m\u1ea1nh m\u1ebd trong Git, c\u01a1 ch\u1ebf ho\u1ea1t \u0111\u1ed9ng c\u1ee7a n\u00f3 d\u1ef1a tr\u00ean vi\u1ec7c di chuy\u1ec3n con tr\u1ecf HEAD, l\u00e0m thay \u0111\u1ed5i l\u1ecbch s\u1eed commit v\u00e0 \u0111i\u1ec1u ch\u1ec9nh tr\u1ea1ng th\u00e1i t\u1eadp tin trong Repository, Staging Area v\u00e0 Working Directory.<\/span><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1490\" height=\"810\" src=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-2-vippro.png\" alt=\"git reset - itviec blog\" class=\"wp-image-83620\" srcset=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-2-vippro.png 1490w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-2-vippro-300x163.png 300w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-2-vippro-640x348.png 640w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-2-vippro-200x109.png 200w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-2-vippro-768x418.png 768w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-2-vippro-100x54.png 100w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-2-vippro-700x381.png 700w\" sizes=\"auto, (max-width: 1490px) 100vw, 1490px\" \/><\/figure>\n\n\n\n<p><span style=\"font-weight: 400;\">C\u00e1c git ho\u1ea1t \u0111\u1ed9ng c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c m\u00f4 t\u1ea3 theo c\u00e1c b\u01b0\u1edbc sau:<\/span><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><span style=\"font-weight: 400;\">X\u00e1c \u0111\u1ecbnh commit v\u00e0 di chuy\u1ec3n HEAD: con tr\u1ecf HEAD s\u1ebd \u0111\u01b0\u1ee3c di chuy\u1ec3n \u0111\u1ebfn commit \u0111\u00edch \u0111\u01b0\u1ee3c ch\u1ec9 \u0111\u1ecbnh v\u00e0 xem \u0111\u00f3 l\u00e0 commit cu\u1ed1i c\u00f9ng trong l\u1ecbch s\u1eed<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">Qu\u1ea3n l\u00fd tr\u1ea1ng th\u00e1i t\u1eadp tin trong c\u00e1c khu v\u1ef1c: Git s\u1ebd c\u1eadp nh\u1eadt l\u1ea1i tr\u1ea1ng th\u00e1i c\u1ee7a t\u1eadp tin trong v\u00f9ng Staging v\u00e0 Working Directory d\u1ef1a tr\u00ean c\u00e1c ch\u1ebf \u0111\u1ed9 \u0111\u01b0\u1ee3c ch\u1ec9 \u0111\u1ecbnh.<\/span><\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-cac-ch\u1ebf-d\u1ed9-trong-git-reset\"><span class=\"ez-toc-section\" id=\"Cac_che_do_trong_git_reset\"><\/span><b>C\u00e1c ch\u1ebf \u0111\u1ed9 trong git reset<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><span style=\"font-weight: 400;\">Ch\u00fang ta h\u00e3y c\u00f9ng t\u00ecm hi\u1ec3u v\u1ec1 c\u01a1 ch\u1ebf ho\u1ea1t \u0111\u1ed9ng, c\u00e1ch s\u1eed d\u1ee5ng c\u00e1c ch\u1ebf \u0111\u1ed9 reset th\u00f4ng qua v\u00ed d\u1ee5 sau:<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">Ch\u00fang ta c\u00f3 m\u1ed9t l\u1ecbch s\u1eed commit bao g\u1ed3m 2 commit:<\/span><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"540\" height=\"61\" src=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-3-vippro.png\" alt=\"git reset - itviec blog\" class=\"wp-image-83621\" srcset=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-3-vippro.png 540w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-3-vippro-300x34.png 300w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-3-vippro-200x23.png 200w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-3-vippro-100x11.png 100w\" sizes=\"auto, (max-width: 540px) 100vw, 540px\" \/><\/figure>\n\n\n\n<p><span style=\"font-weight: 400;\"><\/span><span style=\"font-weight: 400;\">B\u00ean c\u1ea1nh \u0111\u00f3 l\u00e0 s\u1ef1 thay \u0111\u1ed5i trong Staging Area v\u00e0 Working Directory nh\u01b0 sau:<\/span><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"851\" height=\"184\" src=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-4-vippro.png\" alt=\"git reset - itviec blog\" class=\"wp-image-83622\" srcset=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-4-vippro.png 851w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-4-vippro-300x65.png 300w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-4-vippro-640x138.png 640w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-4-vippro-200x43.png 200w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-4-vippro-768x166.png 768w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-4-vippro-100x22.png 100w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-4-vippro-700x151.png 700w\" sizes=\"auto, (max-width: 851px) 100vw, 851px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-mixed-ch\u1ebf-d\u1ed9-m\u1eb7c-d\u1ecbnh\"><b>&#8211;mixed (ch\u1ebf \u0111\u1ed9 m\u1eb7c \u0111\u1ecbnh)<\/b><\/h3>\n\n\n\n<p><span style=\"font-weight: 400;\">C\u00fa ph\u00e1p:<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span style=\"font-weight: 400;\">git reset --mixed &lt;commit&gt;<\/span><\/code><\/pre>\n\n\n\n<p><span style=\"font-weight: 400;\">C\u00f4ng d\u1ee5ng:<\/span><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span style=\"font-weight: 400;\">Di chuy\u1ec3n HEAD v\u1ec1 commit \u0111\u01b0\u1ee3c ch\u1ec9 \u0111\u1ecbnh.<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">X\u00f3a c\u00e1c thay \u0111\u1ed5i trong Staging Area nh\u01b0ng gi\u1eef nguy\u00ean c\u00e1c thay \u0111\u1ed5i trong Working Directory.<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">D\u00f9ng \u0111\u1ec3 s\u1eeda c\u00e1c thay \u0111\u1ed5i staged m\u00e0 b\u1ea1n kh\u00f4ng mu\u1ed1n commit n\u1eefa.<\/span><\/li>\n<\/ul>\n\n\n\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5 s\u1eed d\u1ee5ng th\u00f4ng tin gi\u1ea3 \u0111\u1ecbnh b\u00ean tr\u00ean, ta mu\u1ed1n ho\u00e0n t\u00e1c commit m\u1edbi nh\u1ea5t l\u00e0 \u201cimplement feature login\u201d. B\u1edfi v\u00ec <code>--mixed<\/code> l\u00e0 t\u00f9y ch\u1ecdn m\u1eb7c \u0111\u1ecbnh, v\u00ec v\u1eady ch\u00fang ta c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng c\u00fa ph\u00e1p r\u00fat g\u1ecdn nh\u01b0 sau:<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span style=\"font-weight: 400;\">git reset HEAD~1<\/span><\/code><\/pre>\n\n\n\n<p><span style=\"font-weight: 400;\">L\u00fac n\u00e0y con tr\u1ecf HEAD s\u1ebd \u0111\u01b0\u1ee3c di chuy\u1ec3n \u0111\u1ebfn v\u1ecb tr\u00ed HEAD~1 (commit \u0111\u1ee9ng tr\u01b0\u1edbc commit \u201cimplement feature login\u201d) v\u00e0 c\u00e1c thay \u0111\u1ed5i (bao g\u1ed3m thay \u0111\u1ed5i t\u1eeb commit b\u1ecb reset) s\u1ebd \u0111\u01b0\u1ee3c \u0111\u01b0a tr\u1edf l\u1ea1i Working Directory:<\/span><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"268\" src=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-5-vippro.png\" alt=\"git reset - itviec blog\" class=\"wp-image-83623\" srcset=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-5-vippro.png 640w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-5-vippro-300x126.png 300w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-5-vippro-200x84.png 200w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-5-vippro-100x42.png 100w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/figure>\n\n\n\n<p><span style=\"font-weight: 400;\"><\/span><span style=\"font-weight: 400;\">C\u00f2n l\u1ecbch s\u1eed commit s\u1ebd ch\u1ec9 c\u00f2n l\u1ea1i commit \u201cadd file sample\u201d<\/span><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"561\" height=\"42\" src=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-6-vippro.png\" alt=\"git reset - itviec blog\" class=\"wp-image-83625\" srcset=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-6-vippro.png 561w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-6-vippro-300x22.png 300w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-6-vippro-200x15.png 200w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-6-vippro-100x7.png 100w\" sizes=\"auto, (max-width: 561px) 100vw, 561px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-soft\"><b>&#8211;soft<\/b><\/h3>\n\n\n\n<p><span style=\"font-weight: 400;\">C\u00fa ph\u00e1p:<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span style=\"font-weight: 400;\">git reset --soft &lt;commit&gt;<\/span><\/code><\/pre>\n\n\n\n<p><span style=\"font-weight: 400;\">C\u00f4ng d\u1ee5ng:<\/span><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span style=\"font-weight: 400;\">Git reset <code>--soft<\/code> s\u1ebd di chuy\u1ec3n con tr\u1ecf HEAD v\u1ec1 commit \u0111\u01b0\u1ee3c ch\u1ec9 \u0111\u1ecbnh<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">\u0110\u01b0a c\u00e1c thay \u0111\u1ed5i tr\u1edf l\u1ea1i Staging Area v\u00e0 gi\u1eef nguy\u00ean c\u00e1c thay \u0111\u1ed5i \u1edf Working Directory<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">\u0110\u01b0\u1ee3c s\u1eed d\u1ee5ng khi b\u1ea1n mu\u1ed1n ho\u00e0n t\u00e1c commit nh\u01b0ng v\u1eabn gi\u1eef c\u00e1c thay \u0111\u1ed5i \u1edf Staging Area \u0111\u1ec3 c\u00f3 th\u1ec3 s\u1eeda ho\u1eb7c t\u1ea1o commit m\u1edbi.<\/span><\/li>\n<\/ul>\n\n\n\n<p><span style=\"font-weight: 400;\">S\u1eed d\u1ee5ng th\u00f4ng tin gi\u1ea3 \u0111\u1ecbnh b\u00ean tr\u00ean, v\u00ed d\u1ee5 ta mu\u1ed1n ho\u00e0n t\u00e1c commit m\u1edbi nh\u1ea5t l\u00e0 \u201cimplement feature login\u201d, ta c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng c\u00fa ph\u00e1p nh\u01b0 sau:<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span style=\"font-weight: 400;\">git reset --soft HEAD~1<\/span><\/code><\/pre>\n\n\n\n<p><span style=\"font-weight: 400;\">L\u00fac n\u00e0y con tr\u1ecf HEAD s\u1ebd \u0111\u01b0\u1ee3c di chuy\u1ec3n \u0111\u1ebfn v\u1ecb tr\u00ed HEAD~1 (commit \u0111\u1ee9ng tr\u01b0\u1edbc commit \u201cimplement feature login\u201d) v\u00e0 c\u00e1c thay \u0111\u1ed5i t\u1eeb commit b\u1ecb reset s\u1ebd \u0111\u01b0\u1ee3c \u0111\u01b0a tr\u1edf l\u1ea1i Staging Area, c\u00f2n c\u00e1c thay \u0111\u1ed5i hi\u1ec7n t\u1ea1i \u1edf Staging Area v\u00e0 Working Directory s\u1ebd v\u1eabn \u0111\u01b0\u1ee3c gi\u1eef nguy\u00ean.<\/span><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"646\" height=\"245\" src=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-7-vippro.png\" alt=\"git reset - itviec blog\" class=\"wp-image-83626\" srcset=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-7-vippro.png 646w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-7-vippro-300x114.png 300w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-7-vippro-640x243.png 640w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-7-vippro-200x76.png 200w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-reset-7-vippro-100x38.png 100w\" sizes=\"auto, (max-width: 646px) 100vw, 646px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-hard\"><b>&#8211;hard<\/b><\/h3>\n\n\n\n<p><span style=\"font-weight: 400;\">C\u00fa ph\u00e1p:<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span style=\"font-weight: 400;\">git reset --hard &lt;commit&gt;<\/span><\/code><\/pre>\n\n\n\n<p><span style=\"font-weight: 400;\">C\u00f4ng d\u1ee5ng:<\/span><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span style=\"font-weight: 400;\">Di chuy\u1ec3n HEAD v\u1ec1 commit ch\u1ec9 \u0111\u1ecbnh<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">X\u00f3a m\u1ecdi thay \u0111\u1ed5i trong c\u1ea3 Staging Area v\u00e0 Working Directory<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">C\u1ea9n th\u1eadn: C\u00e1c thay \u0111\u1ed5i ch\u01b0a commit s\u1ebd b\u1ecb m\u1ea5t ho\u00e0n to\u00e0n v\u00e0 kh\u00f4ng th\u1ec3 kh\u00f4i ph\u1ee5c<\/span><\/li>\n<\/ul>\n\n\n\n<p><span style=\"font-weight: 400;\">S\u1eed d\u1ee5ng th\u00f4ng tin gi\u1ea3 \u0111\u1ecbnh b\u00ean tr\u00ean, v\u00ed d\u1ee5 ta mu\u1ed1n ho\u00e0n t\u00e1c commit m\u1edbi nh\u1ea5t l\u00e0 \u201cimplement feature login\u201d, ta c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng c\u00fa ph\u00e1p nh\u01b0 sau:<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span style=\"font-weight: 400;\">git reset --hard HEAD~1<\/span><\/code><\/pre>\n\n\n\n<p><span style=\"font-weight: 400;\">L\u00fac n\u00e0y con tr\u1ecf HEAD s\u1ebd \u0111\u01b0\u1ee3c di chuy\u1ec3n \u0111\u1ebfn v\u1ecb tr\u00ed HEAD~1 (commit \u0111\u1ee9ng tr\u01b0\u1edbc commit \u201cimplement feature login\u201d) v\u00e0 c\u00e1c thay \u0111\u1ed5i t\u1eeb commit b\u1ecb reset s\u1ebd \u0111\u01b0\u1ee3c \u0111\u01b0a tr\u1edf l\u1ea1i Staging Area, nh\u01b0ng c\u00e1c thay \u0111\u1ed5i \u1edf Staging Area v\u00e0 Working Directory s\u1ebd b\u1ecb x\u00f3a b\u1ecf ho\u00e0n to\u00e0n.<\/span><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-merge\"><b>&#8211;merge<\/b><\/h3>\n\n\n\n<p><span style=\"font-weight: 400;\">C\u01a1 ch\u1ebf ho\u1ea1t \u0111\u1ed9ng c\u1ee7a <code>--merge<\/code> s\u1ebd gi\u1ed1ng v\u1edbi <code>--mixed<\/code> khi h\u1ee7y b\u1ecf commit v\u00e0 \u0111\u01b0a t\u1ea5t c\u1ea3 thay \u0111\u1ed5i v\u1ec1 Working Directory. Tuy nhi\u00ean n\u00f3 ch\u1ec9 gi\u1eef l\u1ea1i c\u00e1c thay \u0111\u1ed5i kh\u00f4ng b\u1ecb xung \u0111\u1ed9t.<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">C\u00fa ph\u00e1p:<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span style=\"font-weight: 400;\">git reset --merge &lt;commit&gt;<\/span><\/code><\/pre>\n\n\n\n<p><span style=\"font-weight: 400;\">C\u00f4ng d\u1ee5ng:<\/span><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span style=\"font-weight: 400;\">Di chuy\u1ec3n HEAD v\u1ec1 commit ch\u1ec9 \u0111\u1ecbnh<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">Gi\u1eef l\u1ea1i c\u00e1c thay \u0111\u1ed5i kh\u00f4ng xung \u0111\u1ed9t trong Working Directory<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">N\u1ebfu c\u00f3 xung \u0111\u1ed9t, Git s\u1ebd t\u1ea1m d\u1eebng qu\u00e1 tr\u00ecnh reset v\u00e0 y\u00eau c\u1ea7u x\u1eed l\u00fd th\u1ee7 c\u00f4ng<\/span><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-keep\"><b>&#8211;keep<\/b><\/h3>\n\n\n\n<p><span style=\"font-weight: 400;\">C\u01a1 ch\u1ebf ho\u1ea1t \u0111\u1ed9ng c\u1ee7a <code>--keep<\/code> s\u1ebd gi\u1ed1ng v\u1edbi <code>--mixed<\/code> khi h\u1ee7y b\u1ecf commit v\u00e0 \u0111\u01b0a t\u1ea5t c\u1ea3 thay \u0111\u1ed5i v\u1ec1 Working Directory. Tuy nhi\u00ean n\u00f3 ch\u1ec9 gi\u1eef l\u1ea1i c\u00e1c thay \u0111\u1ed5i kh\u00f4ng b\u1ecb ghi \u0111\u00e8.<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">C\u00fa ph\u00e1p:<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span style=\"font-weight: 400;\">git reset --keep &lt;commit&gt;<\/span><\/code><\/pre>\n\n\n\n<p><span style=\"font-weight: 400;\">C\u00f4ng d\u1ee5ng:<\/span><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span style=\"font-weight: 400;\">Di chuy\u1ec3n HEAD v\u1ec1 commit ch\u1ec9 \u0111\u1ecbnh<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">Gi\u1eef l\u1ea1i c\u00e1c thay \u0111\u1ed5i kh\u00f4ng b\u1ecb ghi \u0111\u00e8 trong Working Directory<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">N\u1ebfu c\u00f3 xung \u0111\u1ed9t, Git s\u1ebd t\u1ea1m d\u1eebng qu\u00e1 tr\u00ecnh reset v\u00e0 y\u00eau c\u1ea7u x\u1eed l\u00fd th\u1ee7 c\u00f4ng<\/span><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-nh\u1eefng-tr\u01b0\u1eddng-h\u1ee3p-s\u1eed-d\u1ee5ng-va-l\u01b0u-y-khi-dung-git-reset\"><span class=\"ez-toc-section\" id=\"Nhung_truong_hop_su_dung_va_luu_y_khi_dung_git_reset\"><\/span><b>Nh\u1eefng tr\u01b0\u1eddng h\u1ee3p s\u1eed d\u1ee5ng v\u00e0 l\u01b0u \u00fd khi d\u00f9ng git reset<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><span style=\"font-weight: 400;\">Git reset l\u00e0 m\u1ed9t l\u1ec7nh m\u1ea1nh m\u1ebd trong Git. N\u00f3 \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng trong nhi\u1ec1u tr\u01b0\u1eddng h\u1ee3p khi k\u1ebft h\u1ee3p v\u1edbi c\u00e1c t\u00f9y ch\u1ecdn:<\/span><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><span style=\"font-weight: 400;\">Ch\u1ec9nh s\u1eeda commit m\u1edbi nh\u1ea5t: s\u1eed d\u1ee5ng <code>--soft<\/code> \u0111\u1ec3 h\u1ee7y commit m\u1edbi nh\u1ea5t v\u00e0 \u0111\u01b0a c\u00e1c thay \u0111\u1ed5i v\u1ec1 l\u1ea1i staging area. Sau \u0111\u00f3 c\u00f3 th\u1ec3 ti\u1ebfn h\u00e0nh ch\u1ec9nh s\u1eeda \u0111\u1ec3 t\u1ea1o l\u1ea1i commit m\u1edbi<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">Lo\u1ea1i b\u1ecf c\u00e1c file \u0111\u00e3 \u0111\u01b0\u1ee3c th\u00eam v\u00e0o Staging Area: s\u1eed d\u1ee5ng <code>--mixed<\/code> \u0111\u1ec3 \u0111\u01b0a c\u00e1c thay \u0111\u1ed5i trong khu v\u1ef1c Staging Area v\u1ec1 l\u1ea1i Working Directory. Tuy nhi\u00ean h\u00e0nh \u0111\u1ed9ng n\u00e0y c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c thao t\u00e1c d\u1ec5 d\u00e0ng tr\u00ean c\u00e1c IDE nh\u01b0 VScode<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">X\u00f3a b\u1ecf commit v\u00e0 n\u1ed9i dung thay \u0111\u1ed5i m\u00e0 kh\u00f4ng \u0111\u1ec3 l\u1ea1i d\u1ea5u v\u1ebft: s\u1eed d\u1ee5ng <span style=\"font-weight: 400;\"><code>--hard<\/code><\/span> \u0111\u1ec3 h\u1ee7y b\u1ecf commit c\u0169ng nh\u01b0 x\u00f3a b\u1ecf t\u1ea5t c\u1ea3 thay \u0111\u1ed5i trong Staging Area v\u00e0 Working Directory<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">Khi mu\u1ed1n ho\u00e0n t\u00e1c c\u00e1c commit ch\u01b0a \u0111\u01b0\u1ee3c \u0111\u1ea9y l\u00ean remote repository<\/span><\/li>\n<\/ol>\n\n\n\n<p><span style=\"font-weight: 400;\">M\u1eb7c d\u00f9 Git reset cung c\u1ea5p c\u00e1c kh\u1ea3 n\u0103ng m\u1ea1nh m\u1ebd \u0111\u1ec3 thay \u0111\u1ed5i l\u1ecbch s\u1eed commit c\u0169ng nh\u01b0 qu\u1ea3n l\u00fd tr\u1ea1ng th\u00e1i thay \u0111\u1ed5i c\u1ee7a t\u1eadp tin. Tuy nhi\u00ean n\u00f3 c\u0169ng ti\u1ec1m \u1ea9n nhi\u1ec1u r\u1ee7i ro n\u1ebfu kh\u00f4ng \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u00fang c\u00e1ch. D\u01b0\u1edbi \u0111\u00e2y l\u00e0 m\u1ed9t s\u1ed1 l\u01b0u \u00fd khi s\u1eed d\u1ee5ng git reset:<\/span><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><span style=\"font-weight: 400;\">Git reset <span style=\"font-weight: 400;\"><code>--hard<\/code><\/span> c\u00f3 th\u1ec3 g\u00e2y m\u1ea5t d\u1eef li\u1ec7u: B\u1edfi v\u00ec <code>--hard<\/code> s\u1ebd h\u1ee7y b\u1ecf to\u00e0n b\u1ed9 c\u00e1c thay \u0111\u1ed5i trong commit b\u1ecb reset v\u00e0 d\u1eef li\u1ec7u thay \u0111\u1ed5i ch\u01b0a \u0111\u01b0\u1ee3c commit. V\u00ec v\u1eady h\u00e3y ch\u1eafc ch\u1eafn r\u1eb1ng kh\u00f4ng c\u00f3 d\u1eef li\u1ec7u n\u00e0o c\u1ea7n \u0111\u01b0\u1ee3c gi\u1eef l\u1ea1i tr\u01b0\u1edbc khi th\u1ef1c hi\u1ec7n <span style=\"font-weight: 400;\"><code>--hard<\/code><\/span><\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">Kh\u00f4ng s\u1eed d\u1ee5ng git reset khi \u0111\u00e3 \u0111\u1ea9y commit l\u00ean remote repository: B\u1edfi v\u00ec git reset c\u00f3 th\u1ec3 l\u00e0m thay \u0111\u1ed5i l\u1ecbch s\u1eed commit, v\u00ec v\u1eady vi\u1ec7c th\u1ef1c hi\u1ec7n git reset tr\u00ean remote repository c\u00f3 th\u1ec3 d\u1eabn \u0111\u1ebfn xung \u0111\u1ed9t v\u00e0 m\u1ea5t d\u1eef li\u1ec7u v\u1edbi nh\u1eefng th\u00e0nh vi\u00ean kh\u00e1c.<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">Lu\u00f4n ki\u1ec3m tra tr\u1ea1ng th\u00e1i l\u1ecbch s\u1eed commit tr\u01b0\u1edbc khi reset: \u0110i\u1ec1u n\u00e0y gi\u00fap b\u1ea1n \u0111\u1ea3m b\u1ea3o r\u1eb1ng \u0111\u00e3 kh\u00f4ng th\u1ef1c hi\u1ec7n reset nh\u1ea7m commit.<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">S\u1eed d\u1ee5ng Git stash tr\u01b0\u1edbc khi reset: \u0110i\u1ec1u n\u00e0y gi\u00fap tr\u00e1nh b\u1ecb m\u1ea5t d\u1eef li\u1ec7u ch\u01b0a \u0111\u01b0\u1ee3c commit n\u1ebfu s\u1eed d\u1ee5ng <span style=\"font-weight: 400;\"><code>--hard<\/code><\/span> ho\u1eb7c tr\u00e1nh b\u1ecb xung \u0111\u1ed9t khi s\u1eed d\u1ee5ng c\u00e1c ch\u1ebf \u0111\u1ed9 kh\u00e1c.<\/span><\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-so-sanh-git-reset-va-git-revert\"><span class=\"ez-toc-section\" id=\"So_sanh_git_reset_va_git_revert\"><\/span><b>So s\u00e1nh git reset v\u00e0 git revert<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><span style=\"font-weight: 400;\">Git reset v\u00e0 Git revert \u0111\u01b0\u1ee3c \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 ho\u00e0n t\u00e1c c\u00e1c thay \u0111\u1ed5i trong repository. Tuy nhi\u00ean c\u01a1 ch\u1ebf ho\u1ea1t \u0111\u1ed9ng c\u1ee7a ch\u00fang l\u1ea1i ho\u00e0n to\u00e0n kh\u00e1c nhau:<\/span><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><b>Ti\u00eau ch\u00ed<\/b><\/td><td><b>Git reset<\/b><\/td><td><b>Git revert<\/b><\/td><\/tr><tr><td><span style=\"font-weight: 400;\">C\u00fa ph\u00e1p<\/span><\/td><td><span style=\"font-weight: 400;\">git reset &lt;options&gt; &lt;commit&gt;<\/span><\/td><td><span style=\"font-weight: 400;\">git revert &lt;commit&gt;<\/span><\/td><\/tr><tr><td><span style=\"font-weight: 400;\">C\u01a1 ch\u1ebf ho\u1ea1t \u0111\u1ed9ng<\/span><\/td><td><span style=\"font-weight: 400;\">Ho\u00e0n t\u00e1c commit b\u1eb1ng c\u00e1ch thay \u0111\u1ed5i l\u1ecbch s\u1eed, v\u1ecb tr\u00ed con tr\u1ecf HEAD<\/span><\/td><td><span style=\"font-weight: 400;\">T\u1ea1o commit m\u1edbi v\u1edbi n\u1ed9i dung \u0111\u1ea3o ng\u01b0\u1ee3c so v\u1edbi commit c\u1ea7n ho\u00e0n t\u00e1c<\/span><\/td><\/tr><tr><td><span style=\"font-weight: 400;\">Thay \u0111\u1ed5i l\u1ecbch s\u1eed commit<\/span><\/td><td><span style=\"font-weight: 400;\">Thay \u0111\u1ed5i l\u1ecbch s\u1eed commit (x\u00f3a b\u1ecf commit kh\u1ecfi l\u1ecbch s\u1eed)<\/span><\/td><td><span style=\"font-weight: 400;\">Gi\u1eef nguy\u00ean l\u1ecbch s\u1eed, ch\u1ec9 b\u1ed5 sung commit \u0111\u1ea3o ng\u01b0\u1ee3c<\/span><\/td><\/tr><tr><td><span style=\"font-weight: 400;\">Thay \u0111\u1ed5i Staging Area, Working Directory<\/span><\/td><td><span style=\"font-weight: 400;\">C\u00f3 th\u1ec3 l\u00e0m thay \u0111\u1ed5i t\u00f9y thu\u1ed9c v\u00e0o c\u01a1 ch\u1ebf s\u1eed d\u1ee5ng<\/span><\/td><td><span style=\"font-weight: 400;\">Kh\u00f4ng l\u00e0m thay \u0111\u1ed5i<\/span><\/td><\/tr><tr><td><span style=\"font-weight: 400;\">Ph\u1ea1m vi s\u1eed d\u1ee5ng<\/span><\/td><td><span style=\"font-weight: 400;\">Ch\u1ec9 n\u00ean s\u1eed d\u1ee5ng \u1edf nh\u00e1nh c\u1ee5c b\u1ed9, ch\u01b0a \u0111\u01b0\u1ee3c \u0111\u1ea9y l\u00ean remote repository<\/span><\/td><td><span style=\"font-weight: 400;\">An to\u00e0n khi s\u1eed d\u1ee5ng tr\u00ean remote repository<\/span><\/td><\/tr><tr><td><span style=\"font-weight: 400;\">Tr\u01b0\u1eddng h\u1ee3p s\u1eed d\u1ee5ng<\/span><\/td><td><span style=\"font-weight: 400;\">X\u00f3a commit kh\u1ecfi l\u1ecbch s\u1eed v\u00e0 kh\u00f4ng l\u01b0u l\u1ea1i d\u1ea5u v\u1ebft<\/span><\/td><td><span style=\"font-weight: 400;\">Khi c\u1ea7n ho\u00e0n t\u00e1c commit nh\u01b0ng v\u1eabn gi\u1eef nguy\u00ean l\u1ecbch s\u1eed<\/span><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>\u0110\u1ecdc chi ti\u1ebft: <strong><a href=\"https:\/\/itviec.com\/blog\/git-revert-la-gi\/\" target=\"_blank\" rel=\"noreferrer noopener\">Git revert: H\u01b0\u1edbng d\u1eabn c\u00e1ch ho\u00e0n t\u00e1c l\u1ecbch s\u1eed b\u1eb1ng Git Revert<\/a><\/strong><\/em><\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-cac-cau-h\u1ecfi-th\u01b0\u1eddng-g\u1eb7p-v\u1ec1-git-reset\"><span class=\"ez-toc-section\" id=\"Cac_cau_hoi_thuong_gap_ve_Git_reset\"><\/span><strong>C\u00e1c c\u00e2u h\u1ecfi th\u01b0\u1eddng g\u1eb7p v\u1ec1 Git reset<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-so-sanh-gi\u1eefa-git-reset-va-git-checkout\"><b>So s\u00e1nh gi\u1eefa git reset v\u00e0 git checkout<\/b><\/h3>\n\n\n\n<p><span style=\"font-weight: 400;\">Git reset v\u00e0 Git checkout l\u00e0 hai l\u1ec7nh h\u1eefu \u00edch,&nbsp; ph\u1ed5 bi\u1ebfn trong Git. M\u1eb7c d\u00f9 ch\u00fang \u0111\u1ec1u c\u00f3 t\u00e1c \u0111\u1ed9ng \u0111\u1ebfn con tr\u1ecf HEAD, tuy nhi\u00ean ch\u00fang c\u00f3 nh\u1eefng ch\u1ee9c n\u0103ng v\u00e0 tr\u01b0\u1eddng h\u1ee3p s\u1eed d\u1ee5ng kh\u00e1c nhau, d\u01b0\u1edbi \u0111\u00e2y l\u00e0 b\u1ea3ng so s\u00e1nh chi ti\u1ebft:<\/span><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><b>Ti\u00eau ch\u00ed<\/b><\/td><td><b>Git reset<\/b><\/td><td><b>Git checkout<\/b><\/td><\/tr><tr><td><span style=\"font-weight: 400;\">C\u00e1ch ho\u1ea1t \u0111\u1ed9ng<\/span><\/td><td><span style=\"font-weight: 400;\">\u0110\u01b0a con tr\u1ecf HEAD v\u1ec1 commit \u0111\u01b0\u1ee3c ch\u1ec9 \u0111\u1ecbnh v\u00e0 lo\u1ea1i b\u1ecf commit \u0111\u1ee9ng sau n\u00f3.<\/span><\/td><td><span style=\"font-weight: 400;\">Di chuy\u1ec3n HEAD sang m\u1ed9t nh\u00e1nh kh\u00e1c ho\u1eb7c commit kh\u00e1c<\/span><\/td><\/tr><tr><td><span style=\"font-weight: 400;\">Thay \u0111\u1ed5i l\u1ecbch s\u1eed commit<\/span><\/td><td><span style=\"font-weight: 400;\">C\u00f3, x\u00f3a b\u1ecf commit kh\u1ecfi l\u1ecbch s\u1eed<\/span><\/td><td><span style=\"font-weight: 400;\">Kh\u00f4ng l\u00e0m thay \u0111\u1ed5i l\u1ecbch s\u1eed<\/span><\/td><\/tr><tr><td><span style=\"font-weight: 400;\">M\u1ee5c \u0111\u00edch<\/span><\/td><td><span style=\"font-weight: 400;\">Ho\u00e0n t\u00e1c commit v\u00e0 thay \u0111\u1ed5i l\u1ecbch s\u1eed<\/span><\/td><td><span style=\"font-weight: 400;\">Chuy\u1ec3n nh\u00e1nh ho\u1eb7c kh\u00f4i ph\u1ee5c t\u1eadp tin<\/span><\/td><\/tr><tr><td><span style=\"font-weight: 400;\">\u1ea2nh h\u01b0\u1edfng Staging Area<\/span><\/td><td><span style=\"font-weight: 400;\">C\u00f3 th\u1ec3 thay \u0111\u1ed5i<\/span><\/td><td><span style=\"font-weight: 400;\">Kh\u00f4ng<\/span><\/td><\/tr><tr><td><span style=\"font-weight: 400;\">\u1ea2nh h\u01b0\u1edfng Working Directory<\/span><\/td><td><span style=\"font-weight: 400;\">C\u00f3 th\u1ec3 thay \u0111\u1ed5i<\/span><\/td><td><span style=\"font-weight: 400;\">Ch\u1ec9 thay \u0111\u1ed5i file ho\u1eb7c nh\u00e1nh<\/span><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>\u0110\u1ecdc th\u00eam: <a href=\"https:\/\/itviec.com\/blog\/git-checkout-la-gi\/\" target=\"_blank\" rel=\"noopener\"><strong>Git Checkout: C\u00e1c tr\u01b0\u1eddng h\u1ee3p s\u1eed d\u1ee5ng k\u00e8m v\u00ed d\u1ee5 chi ti\u1ebft<\/strong><\/a><\/em><\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-lam-sao-d\u1ec3-khoi-ph\u1ee5c-d\u1eef-li\u1ec7u-khi-vo-tinh-dung-git-reset-hard\"><b>L\u00e0m sao \u0111\u1ec3 kh\u00f4i ph\u1ee5c d\u1eef li\u1ec7u khi v\u00f4 t\u00ecnh d\u00f9ng \u201cgit reset &#8211;hard\u201d<\/b><\/h3>\n\n\n\n<p><span style=\"font-weight: 400;\">N\u1ebfu b\u1ea1n v\u00f4 t\u00ecnh s\u1eed d\u1ee5ng <code>git reset --hard<\/code> d\u1eabn \u0111\u1ebfn commit b\u1ecb x\u00f3a v\u00e0 n\u1ed9i dung thay \u0111\u1ed5i trong \u0111\u00f3 c\u0169ng bi\u1ebfn m\u1ea5t. L\u00fac n\u00e0y b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng git reflog \u0111\u1ec3 truy v\u1ebft l\u1ecbch s\u1eed v\u00e0 l\u1ea5y l\u1ea1i n\u1ed9i dung \u0111\u00e3 m\u1ea5t.<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">Git reflog l\u00e0 m\u1ed9t l\u1ec7nh \u0111\u1ec3 xem l\u1ea1i t\u1ea5t c\u1ea3 c\u00e1c thay \u0111\u1ed5i di\u1ec5n ra trong repositoryv\u00e0 ch\u00fang ta c\u00f3 th\u1ec3 truy xu\u1ea5t \u0111\u1ebfn tr\u1ea1ng th\u00e1i c\u1ee7a m\u00e3 ngu\u1ed3n t\u1ea1i th\u1eddi \u0111i\u1ec3m di\u1ec5n ra c\u00e1c thay \u0111\u1ed5i \u0111\u00f3.<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5:<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">Trong nh\u00e1nh main \u0111ang c\u00f3 2 commit nh\u01b0 sau:<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span style=\"font-weight: 400;\">def5678 HEAD@{1}: commit: S\u1eeda l\u1ed7i ch\u1ee9c n\u0103ng t\u00ecm ki\u1ebfm<\/span>\n<span style=\"font-weight: 400;\">ghi9012 HEAD@{2}: commit: T\u1ea1o t\u00ednh n\u0103ng t\u00ecm ki\u1ebfm<\/span><\/code><\/pre>\n\n\n\n<p><span style=\"font-weight: 400;\">B\u1ea1n s\u1eed d\u1ee5ng git reset <span style=\"font-weight: 400;\"><code>--hard<\/code><\/span> \u0111\u1ec3 x\u00f3a commit \u201cS\u1eeda l\u1ed7i ch\u1ee9c n\u0103ng t\u00ecm ki\u1ebfm\u201d, nh\u01b0ng b\u00e2y gi\u1edd b\u1ea1n c\u1ea7n \u0111\u01b0a commit n\u00e0y tr\u1edf l\u1ea1i, l\u00fac n\u00e0y b\u1ea1n s\u1eed d\u1ee5ng git reflog \u0111\u1ec3 xem l\u1ea1i ho\u1ea1t \u0111\u1ed9ng nh\u01b0 sau:<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span style=\"font-weight: 400;\">git reflog<\/span><\/code><\/pre>\n\n\n\n<p><span style=\"font-weight: 400;\">Output:<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span style=\"font-weight: 400;\">abc1234 (HEAD -&gt; main) HEAD@{0}: reset: moving to HEAD~1<\/span>\n<span style=\"font-weight: 400;\">def5678 HEAD@{1}: commit: S\u1eeda l\u1ed7i ch\u1ee9c n\u0103ng t\u00ecm ki\u1ebfm<\/span>\n<span style=\"font-weight: 400;\">ghi9012 HEAD@{2}: commit: T\u1ea1o t\u00ednh n\u0103ng t\u00ecm ki\u1ebfm<\/span><\/code><\/pre>\n\n\n\n<p><span style=\"font-weight: 400;\">Trong \u0111\u00f3 ta s\u1ebd th\u1ea5y:<\/span><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span style=\"font-weight: 400;\">HEAD@{0} l\u00e0 commit hi\u1ec7n t\u1ea1i sau khi <code>git reset --hard<\/code>.<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">HEAD@{1}, HEAD@{2} l\u00e0 c\u00e1c commit tr\u01b0\u1edbc khi b\u1ecb reset.<\/span><\/li>\n<\/ul>\n\n\n\n<p><span style=\"font-weight: 400;\">B\u00e2y gi\u1edd, \u0111\u1ec3 l\u1ea5y l\u1ea1i commit \u201cS\u1eeda l\u1ed7i ch\u1ee9c n\u0103ng t\u00ecm ki\u1ebfm\u201d, ta c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng git reset k\u1ebft h\u1ee3p v\u1edbi commit hash c\u1ee7a commit \u0111\u00f3:<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span style=\"font-weight: 400;\">git reset --hard def5678<\/span><\/code><\/pre>\n\n\n\n<p><span style=\"font-weight: 400;\">L\u00fac n\u00e0y, l\u1ecbch s\u1eed commit s\u1ebd tr\u1edf l\u1ea1i c\u00f3 2 commit nh\u01b0 ban \u0111\u1ea7u.<\/span><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-s\u1ef1-khac-bi\u1ec7t-gi\u1eefa-head-va-head-khi-dung-git-reset\"><b>S\u1ef1 kh\u00e1c bi\u1ec7t gi\u1eefa HEAD~ v\u00e0 HEAD^ khi d\u00f9ng git reset<\/b><\/h3>\n\n\n\n<p><span style=\"font-weight: 400;\">Khi s\u1eed d\u1ee5ng git reset, HEAD~ v\u00e0 HEAD^ l\u00e0 c\u00e1c tham chi\u1ebfu commit \u0111\u1ec3 ch\u1ec9 \u0111\u1ecbnh c\u00e1c commit tr\u01b0\u1edbc \u0111\u00f3. Tuy nhi\u00ean gi\u1eefa ch\u00fang c\u00f3 m\u1ed9t s\u1ed1 kh\u00e1c bi\u1ec7t sau:<\/span><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-head\"><b>HEAD~<\/b><\/h4>\n\n\n\n<p><span style=\"font-weight: 400;\">HEAD~x d\u00f9ng \u0111\u1ec3 ch\u1ec9 commit x commit tr\u01b0\u1edbc so v\u1edbi HEAD. N\u1ebfu kh\u00f4ng ch\u1ec9 \u0111\u1ecbnh s\u1ed1 x, m\u1eb7c \u0111\u1ecbnh l\u00e0 HEAD~1, t\u1ee9c l\u00e0 commit ngay tr\u01b0\u1edbc HEAD. V\u00ed d\u1ee5 ta c\u00f3:<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span style=\"font-weight: 400;\">abc123 (HEAD -&gt; main) Commit A<\/span>\n<span style=\"font-weight: 400;\">def456 Commit B<\/span>\n<span style=\"font-weight: 400;\">ghi789 Commit C<\/span><\/code><\/pre>\n\n\n\n<p><span style=\"font-weight: 400;\">L\u00fac n\u00e0y, HEAD~1 s\u1ebd t\u01b0\u01a1ng \u1ee9ng v\u1edbi commit B v\u00e0 HEAD~2 s\u1ebd t\u01b0\u01a1ng \u1ee9ng v\u1edbi commit C.<\/span><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-head-0\"><b>HEAD^<\/b><\/h4>\n\n\n\n<p><span style=\"font-weight: 400;\">HEAD^ s\u1ebd tr\u1ecf \u0111\u1ebfn commit cha (commit li\u1ec1n k\u1ec1 tr\u01b0\u1edbc) c\u1ee7a commit hi\u1ec7n t\u1ea1i.<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">\u0110i\u1ec1u n\u00e0y \u0111\u1eb7c bi\u1ec7t h\u1eefu \u00edch \u0111\u1ed1i v\u1edbi commit merge. N\u1ebfu HEAD hi\u1ec7n t\u1ea1i \u0111ang l\u00e0 m\u1ed9t commit merge (\u0111\u01b0\u1ee3c t\u1ea1o ra t\u1eeb ho\u1ea1t \u0111\u1ed9ng git merge), th\u00ec HEAD^1 s\u1ebd t\u01b0\u01a1ng \u1ee9ng v\u1edbi commit li\u1ec1n k\u1ec1 tr\u01b0\u1edbc \u0111\u00f3 \u1edf nh\u00e1nh ch\u00ednh hi\u1ec7n t\u1ea1i v\u00e0 HEAD^2 s\u1ebd t\u01b0\u01a1ng \u1ee9ng v\u1edbi commit li\u1ec1n k\u1ec1 tr\u01b0\u1edbc \u0111\u00f3 \u1edf nh\u00e1nh ph\u1ee5.<\/span><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-t\u1ed5ng-k\u1ebft\"><span class=\"ez-toc-section\" id=\"Tong_ket\"><\/span><b>T\u1ed5ng k\u1ebft<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><span style=\"font-weight: 400;\">Git reset l\u00e0 m\u1ed9t c\u00f4ng c\u1ee5 h\u1eefu \u00edch \u0111\u1ec3 b\u1ea1n c\u00f3 th\u1ec3 ki\u1ec3m so\u00e1t, ch\u1ec9nh s\u1eeda v\u00e0 ho\u00e0n t\u00e1c c\u00e1c commits m\u1ed9t c\u00e1ch d\u1ec5 d\u00e0ng. Tuy nhi\u00ean \u0111\u1ec3 s\u1eed d\u1ee5ng n\u00f3 \u0111\u01b0\u1ee3c hi\u1ec7u qu\u1ea3 v\u00e0 tr\u00e1nh c\u00e1c s\u1ef1 c\u1ed1 ngo\u00e0i \u00fd mu\u1ed1n, c\u1ea7n \u0111\u00f2i h\u1ecfi l\u1eadp tr\u00ecnh vi\u00ean ph\u1ea3i hi\u1ec3u r\u00f5 \u0111\u01b0\u1ee3c c\u01a1 ch\u1ebf ho\u1ea1t \u0111\u1ed9ng v\u00e0 c\u00e1ch s\u1eed d\u1ee5ng n\u00f3.<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">Qua b\u00e0i vi\u1ebft n\u00e0y, ITviec hi v\u1ecdng \u0111\u00e3 mang \u0111\u1ebfn cho b\u1ea1n \u0111\u1ecdc nh\u1eefng th\u00f4ng tin h\u1eefu \u00edch v\u1ec1 c\u00e1ch s\u1eed d\u1ee5ng Git reset, \u0111\u1ec3 b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng hi\u1ec7u qu\u1ea3 v\u00e0 t\u1eebng b\u01b0\u1edbc l\u00e0m ch\u1ee7 \u0111\u01b0\u1ee3c h\u1ec7 th\u1ed1ng qu\u1ea3n l\u00fd phi\u00ean b\u1ea3n Git.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Khi l\u00e0m vi\u1ec7c v\u1edbi Git, vi\u1ec7c t\u1ea1o ra c\u00e1c commit nh\u1eb1m l\u01b0u tr\u1eef l\u1ea1i c\u00e1c thay \u0111\u1ed5i \u0111\u00e3 th\u1ef1c hi\u1ec7n tr\u00ean m\u00e3 ngu\u1ed3n v\u00e0o kho l\u01b0u tr\u1eef Git. Tuy nhi\u00ean s\u1ebd c\u00f3 nh\u1eefng tr\u01b0\u1eddng h\u1ee3p m\u00e0 ch\u00fang ta c\u1ea7n h\u1ee7y b\u1ecf nh\u1eefng commit n\u00e0y, ch\u1eb3ng h\u1ea1n nh\u01b0 c\u00f3 l\u1ed7i trong c\u00e1c thay \u0111\u1ed5i, commit nh\u1ea7m [&hellip;]<\/p>\n","protected":false},"author":235,"featured_media":83627,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_gspb_post_css":"","footnotes":""},"categories":[109],"tags":[],"class_list":["post-83252","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-chuyen-mon-it"],"blocksy_meta":[],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.8 (Yoast SEO v27.8) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Git Reset: H\u01b0\u1edbng d\u1eabn c\u00e1ch x\u00f3a commit b\u1eb1ng Git Reset - ITviec Blog<\/title>\n<meta name=\"description\" content=\"Git Reset gi\u00fap ho\u00e0n t\u00e1c c\u00e1c thay \u0111\u1ed5i \u0111\u00e3 \u0111\u01b0\u1ee3c commit v\u00e0 l\u01b0u tr\u1eef trong repository. Kh\u00e1m ph\u00e1 c\u01a1 ch\u1ebf, ph\u00e2n lo\u1ea1i v\u00e0 c\u00e1ch s\u1eed d\u1ee5ng Git reset.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/itviec.com\/blog\/git-reset-la-gi\/\" \/>\n<meta property=\"og:locale\" content=\"vi_VN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Git Reset: H\u01b0\u1edbng d\u1eabn c\u00e1ch x\u00f3a commit b\u1eb1ng Git Reset\" \/>\n<meta property=\"og:description\" content=\"Khi l\u00e0m vi\u1ec7c v\u1edbi Git, vi\u1ec7c t\u1ea1o ra c\u00e1c commit nh\u1eb1m l\u01b0u tr\u1eef l\u1ea1i c\u00e1c thay \u0111\u1ed5i \u0111\u00e3 th\u1ef1c hi\u1ec7n tr\u00ean m\u00e3 ngu\u1ed3n v\u00e0o kho l\u01b0u tr\u1eef Git. Tuy nhi\u00ean s\u1ebd c\u00f3 nh\u1eefng tr\u01b0\u1eddng\" \/>\n<meta property=\"og:url\" content=\"https:\/\/itviec.com\/blog\/git-reset-la-gi\/\" \/>\n<meta property=\"og:site_name\" content=\"ITviec Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ITviec\" \/>\n<meta property=\"article:published_time\" content=\"2024-12-30T11:03:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-07-10T03:49:12+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/Git-reset-vippro.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1500\" \/>\n\t<meta property=\"og:image:height\" content=\"790\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Ph\u1ea1m H\u1eefu Ng\u1ecdc\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ITviec\" \/>\n<meta name=\"twitter:site\" content=\"@ITviec\" \/>\n<meta name=\"twitter:label1\" content=\"\u0110\u01b0\u1ee3c vi\u1ebft b\u1edfi\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ph\u1ea1m H\u1eefu Ng\u1ecdc\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u01af\u1edbc t\u00ednh th\u1eddi gian \u0111\u1ecdc\" \/>\n\t<meta name=\"twitter:data2\" content=\"15 ph\u00fat\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Git Reset: H\u01b0\u1edbng d\u1eabn c\u00e1ch x\u00f3a commit b\u1eb1ng Git Reset - ITviec Blog","description":"Git Reset gi\u00fap ho\u00e0n t\u00e1c c\u00e1c thay \u0111\u1ed5i \u0111\u00e3 \u0111\u01b0\u1ee3c commit v\u00e0 l\u01b0u tr\u1eef trong repository. Kh\u00e1m ph\u00e1 c\u01a1 ch\u1ebf, ph\u00e2n lo\u1ea1i v\u00e0 c\u00e1ch s\u1eed d\u1ee5ng Git reset.","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:\/\/itviec.com\/blog\/git-reset-la-gi\/","og_locale":"vi_VN","og_type":"article","og_title":"Git Reset: H\u01b0\u1edbng d\u1eabn c\u00e1ch x\u00f3a commit b\u1eb1ng Git Reset","og_description":"Khi l\u00e0m vi\u1ec7c v\u1edbi Git, vi\u1ec7c t\u1ea1o ra c\u00e1c commit nh\u1eb1m l\u01b0u tr\u1eef l\u1ea1i c\u00e1c thay \u0111\u1ed5i \u0111\u00e3 th\u1ef1c hi\u1ec7n tr\u00ean m\u00e3 ngu\u1ed3n v\u00e0o kho l\u01b0u tr\u1eef Git. Tuy nhi\u00ean s\u1ebd c\u00f3 nh\u1eefng tr\u01b0\u1eddng","og_url":"https:\/\/itviec.com\/blog\/git-reset-la-gi\/","og_site_name":"ITviec Blog","article_publisher":"https:\/\/www.facebook.com\/ITviec","article_published_time":"2024-12-30T11:03:44+00:00","article_modified_time":"2025-07-10T03:49:12+00:00","og_image":[{"width":1500,"height":790,"url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/Git-reset-vippro.jpg","type":"image\/jpeg"}],"author":"Ph\u1ea1m H\u1eefu Ng\u1ecdc","twitter_card":"summary_large_image","twitter_creator":"@ITviec","twitter_site":"@ITviec","twitter_misc":{"\u0110\u01b0\u1ee3c vi\u1ebft b\u1edfi":"Ph\u1ea1m H\u1eefu Ng\u1ecdc","\u01af\u1edbc t\u00ednh th\u1eddi gian \u0111\u1ecdc":"15 ph\u00fat"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/itviec.com\/blog\/git-reset-la-gi\/#article","isPartOf":{"@id":"https:\/\/itviec.com\/blog\/git-reset-la-gi\/"},"author":{"name":"Ph\u1ea1m H\u1eefu Ng\u1ecdc","@id":"https:\/\/itviec.com\/blog\/#\/schema\/person\/407769a7625b7f955cef615f7a99abad"},"headline":"Git Reset: H\u01b0\u1edbng d\u1eabn c\u00e1ch x\u00f3a commit b\u1eb1ng Git Reset","datePublished":"2024-12-30T11:03:44+00:00","dateModified":"2025-07-10T03:49:12+00:00","mainEntityOfPage":{"@id":"https:\/\/itviec.com\/blog\/git-reset-la-gi\/"},"wordCount":3276,"publisher":{"@id":"https:\/\/itviec.com\/blog\/#organization"},"image":{"@id":"https:\/\/itviec.com\/blog\/git-reset-la-gi\/#primaryimage"},"thumbnailUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/Git-reset-vippro.jpg","articleSection":["Chuy\u00ean m\u00f4n IT"],"inLanguage":"vi"},{"@type":"WebPage","@id":"https:\/\/itviec.com\/blog\/git-reset-la-gi\/","url":"https:\/\/itviec.com\/blog\/git-reset-la-gi\/","name":"Git Reset: H\u01b0\u1edbng d\u1eabn c\u00e1ch x\u00f3a commit b\u1eb1ng Git Reset - ITviec Blog","isPartOf":{"@id":"https:\/\/itviec.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/itviec.com\/blog\/git-reset-la-gi\/#primaryimage"},"image":{"@id":"https:\/\/itviec.com\/blog\/git-reset-la-gi\/#primaryimage"},"thumbnailUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/Git-reset-vippro.jpg","datePublished":"2024-12-30T11:03:44+00:00","dateModified":"2025-07-10T03:49:12+00:00","description":"Git Reset gi\u00fap ho\u00e0n t\u00e1c c\u00e1c thay \u0111\u1ed5i \u0111\u00e3 \u0111\u01b0\u1ee3c commit v\u00e0 l\u01b0u tr\u1eef trong repository. Kh\u00e1m ph\u00e1 c\u01a1 ch\u1ebf, ph\u00e2n lo\u1ea1i v\u00e0 c\u00e1ch s\u1eed d\u1ee5ng Git reset.","breadcrumb":{"@id":"https:\/\/itviec.com\/blog\/git-reset-la-gi\/#breadcrumb"},"inLanguage":"vi","potentialAction":[{"@type":"ReadAction","target":["https:\/\/itviec.com\/blog\/git-reset-la-gi\/"]}]},{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/git-reset-la-gi\/#primaryimage","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/Git-reset-vippro.jpg","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/Git-reset-vippro.jpg","width":1500,"height":790},{"@type":"BreadcrumbList","@id":"https:\/\/itviec.com\/blog\/git-reset-la-gi\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Chuy\u00ean m\u00f4n IT","item":"https:\/\/itviec.com\/blog\/chuyen-mon-it\/"},{"@type":"ListItem","position":2,"name":"Git Reset: H\u01b0\u1edbng d\u1eabn c\u00e1ch x\u00f3a commit b\u1eb1ng Git Reset"}]},{"@type":"WebSite","@id":"https:\/\/itviec.com\/blog\/#website","url":"https:\/\/itviec.com\/blog\/","name":"ITviec Blog","description":"IT Jobs &amp; People in Vietnam","publisher":{"@id":"https:\/\/itviec.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/itviec.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"vi"},{"@type":"Organization","@id":"https:\/\/itviec.com\/blog\/#organization","name":"ITviec","url":"https:\/\/itviec.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2018\/12\/itviec-black-square-facebook.png","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2018\/12\/itviec-black-square-facebook.png","width":1800,"height":1800,"caption":"ITviec"},"image":{"@id":"https:\/\/itviec.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/ITviec","https:\/\/x.com\/ITviec","https:\/\/www.linkedin.com\/company\/itviec","https:\/\/www.youtube.com\/channel\/UCYthAQ3bcGr57M_ag5gHDvQ"]},{"@type":"Person","@id":"https:\/\/itviec.com\/blog\/#\/schema\/person\/407769a7625b7f955cef615f7a99abad","name":"Ph\u1ea1m H\u1eefu Ng\u1ecdc","image":{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/03\/Pham-Huu-Ngoc-technical-content-reviewer-e1712135841473-100x100.jpg","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/03\/Pham-Huu-Ngoc-technical-content-reviewer-e1712135841473-100x100.jpg","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/03\/Pham-Huu-Ngoc-technical-content-reviewer-e1712135841473-100x100.jpg","caption":"Ph\u1ea1m H\u1eefu Ng\u1ecdc"},"url":"https:\/\/itviec.com\/blog\/author\/pham-huu-ngoc-2\/"}]}},"_links":{"self":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/83252","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/users\/235"}],"replies":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/comments?post=83252"}],"version-history":[{"count":3,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/83252\/revisions"}],"predecessor-version":[{"id":89231,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/83252\/revisions\/89231"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/media\/83627"}],"wp:attachment":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/media?parent=83252"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/categories?post=83252"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/tags?post=83252"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}