{"id":83250,"date":"2024-12-30T17:46:49","date_gmt":"2024-12-30T10:46:49","guid":{"rendered":"https:\/\/itviec.com\/blog\/?p=83250"},"modified":"2025-07-10T10:48:30","modified_gmt":"2025-07-10T03:48:30","slug":"git-revert-la-gi","status":"publish","type":"post","link":"https:\/\/itviec.com\/blog\/git-revert-la-gi\/","title":{"rendered":"Git revert: H\u01b0\u1edbng d\u1eabn c\u00e1ch ho\u00e0n t\u00e1c l\u1ecbch s\u1eed b\u1eb1ng Git Revert"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 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-revert-la-gi\/#Git_revert_la_gi\" >Git revert 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-revert-la-gi\/#Co_che_hoat_dong_cua_git_revert\" >C\u01a1 ch\u1ebf ho\u1ea1t \u0111\u1ed9ng c\u1ee7a git revert<\/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-revert-la-gi\/#Cach_su_dung_git_revert\" >C\u00e1ch s\u1eed d\u1ee5ng git revert<\/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-revert-la-gi\/#Nhung_luu_y_khi_su_dung_git_revert\" >Nh\u1eefng l\u01b0u \u00fd khi s\u1eed d\u1ee5ng git revert<\/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-revert-la-gi\/#So_sanh_git_revert_va_git_reset\" >So s\u00e1nh git revert v\u00e0 git reset<\/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-revert-la-gi\/#Cac_cau_hoi_thuong_gap_ve_git_revert\" >C\u00e1c c\u00e2u h\u1ecfi th\u01b0\u1eddng g\u1eb7p v\u1ec1 git revert<\/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-revert-la-gi\/#Tong_ket\" >T\u1ed5ng k\u1ebft<\/a><\/li><\/ul><\/nav><\/div>\n\n<p><em><strong>Trong qu\u00e1 tr\u00ecnh ph\u00e1t tri\u1ec3n ph\u1ea7n m\u1ec1m, vi\u1ec7c m\u1eafc ph\u1ea3i sai l\u1ea7m nh\u01b0 thay \u0111\u1ed5i nh\u1eefng n\u1ed9i dung kh\u00f4ng ch\u00ednh x\u00e1c ho\u1eb7c g\u00e2y ra l\u1ed7i h\u1ec7 th\u1ed1ng trong c\u00e1c commit code l\u00e0 \u0111i\u1ec1u kh\u00f4ng th\u1ec3 tr\u00e1nh kh\u1ecfi. Git cung c\u1ea5p m\u1ed9t c\u00f4ng c\u1ee5 m\u1ea1nh m\u1ebd \u0111\u1ec3 gi\u00fap l\u1eadp tr\u00ecnh vi\u00ean ho\u00e0n t\u00e1c nh\u1eefng thay \u0111\u1ed5i \u0111\u00f3 nh\u01b0ng v\u1eabn \u0111\u1ea3m b\u1ea3o s\u1ef1 nguy\u00ean v\u1eb9n c\u1ee7a l\u1ecbch s\u1eed commit. \u0110\u00f3 ch\u00ednh l\u00e0 git revert.<\/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 revert 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 revert<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">C\u00e1ch s\u1eed d\u1ee5ng Git revert<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">Nh\u1eefng l\u01b0u \u00fd khi s\u1eed d\u1ee5ng Git revert<\/span><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-git-revert-la-gi\"><span class=\"ez-toc-section\" id=\"Git_revert_la_gi\"><\/span><b>Git revert l\u00e0 g\u00ec?<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><span style=\"font-weight: 400;\">Git revert l\u00e0 m\u1ed9t l\u1ec7nh ph\u1ed5 bi\u1ebfn trong Git \u0111\u1ec3 ho\u00e0n t\u00e1c (undo) c\u00e1c thay \u0111\u1ed5i trong commit tr\u01b0\u1edbc \u0111\u00f3 b\u1eb1ng vi\u1ec7c t\u1ea1o ra m\u1ed9t commit m\u1edbi c\u00f3 n\u1ed9i dung \u0111\u1ea3o ng\u01b0\u1ee3c so v\u1edbi commit \u0111\u01b0\u1ee3c revert. Ch\u00ednh v\u00ec \u0111i\u1ec1u n\u00e0y, git revert th\u01b0\u1eddng \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 gi\u1eef cho l\u1ecbch s\u1eed commit \u0111\u01b0\u1ee3c r\u00f5 r\u00e0ng v\u00e0 kh\u00f4ng b\u1ecb thay \u0111\u1ed5i.<\/span><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1474\" height=\"446\" src=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-revert-1-vippro.png\" alt=\"git revert - itviec blog\" class=\"wp-image-83612\" srcset=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-revert-1-vippro.png 1474w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-revert-1-vippro-300x91.png 300w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-revert-1-vippro-640x194.png 640w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-revert-1-vippro-200x61.png 200w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-revert-1-vippro-768x232.png 768w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-revert-1-vippro-100x30.png 100w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-revert-1-vippro-700x212.png 700w\" sizes=\"auto, (max-width: 1474px) 100vw, 1474px\" \/><\/figure>\n\n\n\n<p><span style=\"font-weight: 400;\">C\u00fa ph\u00e1p git revert c\u01a1 b\u1ea3n:<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span style=\"font-weight: 400;\">git revert &lt;commit-hash&gt;<\/span><\/code><\/pre>\n\n\n\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5, b\u1ea1n th\u00eam 1 commit v\u1edbi n\u1ed9i dung thay \u0111\u1ed5i l\u00e0 th\u00eam t\u1eadp tin sample.txt. Tuy nhi\u00ean sau \u0111\u00f3 b\u1ea1n mu\u1ed1n ho\u00e0n t\u00e1c v\u00e0 th\u1ef1c hi\u1ec7n git revert. B\u1ea1n c\u00f3 th\u1ec3 l\u00e0m theo c\u00e1c b\u01b0\u1edbc sau:<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\"><strong>B\u01b0\u1edbc 1:<\/strong> D\u00f9ng git log \u0111\u1ec3 ki\u1ec3m tra <code>commit-hash<\/code> c\u1ee7a commit c\u1ea7n \u0111\u01b0\u1ee3c revert:<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span style=\"font-weight: 400;\">git <\/span><span style=\"font-weight: 400;\">log<\/span><span style=\"font-weight: 400;\"> --oneline<\/span><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"494\" height=\"113\" src=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-revert-2-vippro.png\" alt=\"git revert\" class=\"wp-image-83613\" srcset=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-revert-2-vippro.png 494w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-revert-2-vippro-300x69.png 300w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-revert-2-vippro-200x46.png 200w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-revert-2-vippro-100x23.png 100w\" sizes=\"auto, (max-width: 494px) 100vw, 494px\" \/><\/figure>\n\n\n\n<p><span style=\"font-weight: 400;\"><strong>B\u01b0\u1edbc 2:<\/strong> Th\u1ef1c hi\u1ec7n git revert<\/span>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span style=\"font-weight: 400;\">git revert eecf29f<\/span><\/code><\/pre>\n\n\n\n<p><span style=\"font-weight: 400;\">L\u00fac n\u00e0y git s\u1ebd m\u1edf m\u1ed9t c\u1eeda s\u1ed5 ch\u1ec9nh s\u1eeda cho commit revert, b\u1ea1n c\u00f3 th\u1ec3 tho\u00e1t ch\u1ebf \u0111\u1ed9 ch\u1ec9nh s\u1eeda n\u1ebfu kh\u00f4ng c\u1ea7n thay \u0111\u1ed5i n\u1ed9i dung g\u00ec.<\/span><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"556\" height=\"94\" src=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-revert-3-vippro.png\" alt=\"git revert - itviec blog\" class=\"wp-image-83614\" srcset=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-revert-3-vippro.png 556w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-revert-3-vippro-300x51.png 300w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-revert-3-vippro-200x34.png 200w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-revert-3-vippro-100x17.png 100w\" sizes=\"auto, (max-width: 556px) 100vw, 556px\" \/><\/figure>\n\n\n\n<p><span style=\"font-weight: 400;\">L\u00fac n\u00e0y m\u1ed9t commit m\u1edbi v\u1edbi n\u1ed9i dung thay \u0111\u1ed5i l\u00e0 x\u00f3a t\u1eadp tin sample.txt \u0111\u00e3 \u0111\u01b0\u1ee3c th\u00eam v\u00e0o l\u1ecbch s\u1eed.<\/span><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"473\" height=\"61\" src=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-revert-4-vippro.png\" alt=\"git revert - itviec blog\" class=\"wp-image-83615\" srcset=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-revert-4-vippro.png 473w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-revert-4-vippro-300x39.png 300w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-revert-4-vippro-200x26.png 200w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/git-revert-4-vippro-100x13.png 100w\" sizes=\"auto, (max-width: 473px) 100vw, 473px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-c\u01a1-ch\u1ebf-ho\u1ea1t-d\u1ed9ng-c\u1ee7a-git-revert\"><span class=\"ez-toc-section\" id=\"Co_che_hoat_dong_cua_git_revert\"><\/span><b>C\u01a1 ch\u1ebf ho\u1ea1t \u0111\u1ed9ng c\u1ee7a git revert<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><span style=\"font-weight: 400;\">M\u1ee5c \u0111\u00edch c\u1ee7a git revert l\u00e0 t\u1ea1o ra m\u1ed9t commit m\u1edbi v\u1edbi n\u1ed9i dung \u0111\u1ea3o ng\u01b0\u1ee3c sao v\u1edbi commit \u0111\u01b0\u1ee3c revert, trong khi v\u1eabn gi\u1eef nguy\u00ean l\u1ecbch s\u1eed commit. D\u01b0\u1edbi \u0111\u00e2y l\u00e0 c\u00e1ch m\u00e0 git ho\u1ea1t \u0111\u1ed9ng khi th\u1ef1c thi m\u1ed9t l\u1ec7nh revert:<\/span><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span style=\"font-weight: 400;\">X\u00e1c \u0111\u1ecbnh commit revert: Git x\u00e1c \u0111\u1ecbnh commit c\u1ee5 th\u1ec3 c\u1ea7n ho\u00e0n t\u00e1c d\u1ef1a v\u00e0o commit hash \u0111\u01b0\u1ee3c cung c\u1ea5p<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">T\u1ea1o commit \u0111\u1ea3o ng\u01b0\u1ee3c: Git s\u1ebd \u0111\u1ed1i chi\u1ebfu n\u1ed9i dung trong commit \u0111\u01b0\u1ee3c revert so v\u1edbi commit tr\u01b0\u1edbc n\u00f3 \u0111\u1ec3 l\u1ea5y ra nh\u1eefng thay \u0111\u1ed5i c\u00f3 trong commit. Sau \u0111\u00f3 s\u1ebd t\u1ea1o ra commit m\u1edbi v\u1edbi n\u1ed9i dung ng\u01b0\u1ee3c l\u1ea1i.<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">Th\u00eam commit m\u1edbi v\u00e0o cu\u1ed1i l\u1ecbch s\u1eed commit v\u1edbi th\u00f4ng \u0111i\u1ec7p m\u1eb7c \u0111\u1ecbnh: <em>Revert &#8220;Th\u00f4ng \u0111i\u1ec7p c\u1ee7a commit \u0111\u01b0\u1ee3c revert&#8221;<\/em><\/span><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-cong-d\u1ee5ng-c\u1ee7a-git-revert\"><b>C\u00f4ng d\u1ee5ng c\u1ee7a git revert<\/b><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span style=\"font-weight: 400;\">Ho\u00e0n t\u00e1c n\u1ed9i dung thay \u0111\u1ed5i b\u1eb1ng vi\u1ec7c t\u1ea1o ra m\u1ed9t commit \u0111\u1ea3o ng\u01b0\u1ee3c<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">Gi\u1eef cho l\u1ecbch s\u1eed commit \u0111\u01b0\u1ee3c to\u00e0n v\u1eb9n<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">L\u1ecbch s\u1eed commit \u0111\u01b0\u1ee3c minh b\u1ea1ch v\u00e0 d\u1ec5 d\u00e0ng ki\u1ec3m tra<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">Gi\u00fap tr\u00e1nh xung \u0111\u1ed9t khi c\u1ed9ng t\u00e1c v\u1edbi nhi\u1ec1u ng\u01b0\u1eddi<\/span><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-cach-s\u1eed-d\u1ee5ng-git-revert\"><span class=\"ez-toc-section\" id=\"Cach_su_dung_git_revert\"><\/span><b>C\u00e1ch s\u1eed d\u1ee5ng git revert<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-cac-tr\u01b0\u1eddng-h\u1ee3p-s\u1eed-d\u1ee5ng-git-revert\"><b>C\u00e1c tr\u01b0\u1eddng h\u1ee3p s\u1eed d\u1ee5ng git revert<\/b><\/h3>\n\n\n\n<p><span style=\"font-weight: 400;\">Git revert \u0111\u1eb7c bi\u1ec7t h\u1eefu \u00edch khi s\u1eed d\u1ee5ng \u0111\u1ec3 ho\u00e0n t\u00e1c c\u00e1c thay \u0111\u1ed5i \u0111\u00e3 \u0111\u01b0\u1ee3c commit khi \u1edf trong c\u00e1c tr\u01b0\u1eddng h\u1ee3p:<\/span><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><span style=\"font-weight: 400;\">C\u1ea7n gi\u1eef cho l\u1ecbch s\u1eed commit \u0111\u01b0\u1ee3c to\u00e0n v\u1eb9n<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">N\u1ed9i dung commit \u0111\u00e3 \u0111\u01b0\u1ee3c \u0111\u1ea9y l\u00ean remote repository<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">Khi l\u00e0m vi\u1ec7c nh\u00f3m v\u00e0 tr\u00e1nh g\u00e2y xung \u0111\u1ed9t m\u00e3 ngu\u1ed3n<\/span><\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-nh\u1eefng-tuy-ch\u1ecdn-nang-cao\"><b>Nh\u1eefng t\u00f9y ch\u1ecdn n\u00e2ng cao<\/b><\/h3>\n\n\n\n<p><span style=\"font-weight: 400;\">Git revert c\u00f3 nhi\u1ec1u t\u00f9y ch\u1ecdn \u0111\u1ec3 ho\u00e0n t\u00e1c commit m\u1ed9t c\u00e1ch linh ho\u1ea1t v\u00e0 ph\u00f9 h\u1ee3p trong c\u00e1c t\u00ecnh hu\u1ed1ng kh\u00e1c nhau:<\/span><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-b\u1ecf-qua-vi\u1ec7c-m\u1edf-trinh-so\u1ea1n-th\u1ea3o-no-edit\"><b>B\u1ecf qua vi\u1ec7c m\u1edf tr\u00ecnh so\u1ea1n th\u1ea3o (&#8211;no-edit)<\/b><\/h4>\n\n\n\n<p><span style=\"font-weight: 400;\">Theo m\u1eb7c \u0111\u1ecbnh, khi th\u1ef1c hi\u1ec7n git revert s\u1ebd m\u1edf ra m\u1ed9t tr\u00ecnh so\u1ea1n th\u1ea3o \u0111\u1ec3 ch\u00fang ta c\u00f3 th\u1ec3 thay \u0111\u1ed5i m\u1ed9t s\u1ed1 n\u1ed9i dung cho commit revert. Tuy nhi\u00ean ch\u00fang ta c\u00f3 th\u1ec3 b\u1ecf qua b\u01b0\u1edbc n\u00e0y b\u1eb1ng c\u00e1ch th\u00eam option <code>--no-edit<\/code>:<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span style=\"font-weight: 400;\">git revert --no-edit &lt;commit-hash&gt;<\/span><\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-hoan-tac-nhi\u1ec1u-commit\"><b>Ho\u00e0n t\u00e1c nhi\u1ec1u commit<\/b><\/h4>\n\n\n\n<p><span style=\"font-weight: 400;\">Trong m\u1ed9t s\u1ed1 tr\u01b0\u1eddng h\u1ee3p, ch\u00fang ta c\u1ea7n ho\u00e0n t\u00e1c nhi\u1ec1u commit. Thay v\u00ec th\u1ef1c hi\u1ec7n nhi\u1ec1u l\u1ec7nh commit, b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng c\u00fa ph\u00e1p sau:<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span style=\"font-weight: 400;\">git revert &lt;oldest-commit&gt;..&lt;lastest-commit&gt;<\/span><\/code><\/pre>\n\n\n\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5, m\u00e3 ngu\u1ed3n \u0111ang c\u00f3 5 commit v\u1edbi n\u1ed9i dung nh\u01b0 sau:<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span style=\"font-weight: 400;\">e2v6g7h8 - commit D (HEAD)<\/span>\n<span style=\"font-weight: 400;\">c334e5f6 - commit C<\/span>\n<span style=\"font-weight: 400;\">b2c3d4e5 - commit B<\/span>\n<span style=\"font-weight: 400;\">a1b2c3d4 - commit A<\/span><\/code><\/pre>\n\n\n\n<p><span style=\"font-weight: 400;\">B\u00e2y gi\u1edd ch\u00fang ta c\u1ea7n revert 3 commit cu\u1ed1i c\u00f9ng l\u00e0 B, C, D:<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span style=\"font-weight: 400;\">git revert b2c3d4e5..HEAD<\/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;\">b2c3d4e5: l\u00e0 commit c\u0169 nh\u1ea5t trong ph\u1ea1m vi c\u1ea7n revert<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">HEAD: l\u00e0 commit m\u1edbi nh\u1ea5t c\u1ea7n revert<\/span><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-b\u1ecf-qua-xac-minh-no-verify\"><b>B\u1ecf qua x\u00e1c minh (&#8211;no-verify)<\/b><\/h4>\n\n\n\n<p><span style=\"font-weight: 400;\">S\u1eed d\u1ee5ng \u0111\u1ec3 b\u1ecf qua c\u00e1c c\u01a1 ch\u1ebf x\u00e1c minh tr\u01b0\u1edbc khi commit nh\u01b0 pre-commit, commit hooks:<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span style=\"font-weight: 400;\">git revert --no-verify &lt;commit-hash&gt;<\/span><\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-hoan-tac-commit-merge\"><b>Ho\u00e0n t\u00e1c commit merge<\/b><\/h4>\n\n\n\n<p><span style=\"font-weight: 400;\">M\u1ed9t tr\u01b0\u1eddng h\u1ee3p \u0111\u1eb7c bi\u1ec7t khi th\u1ef1c hi\u1ec7n revert \u0111\u00f3 ch\u00ednh l\u00e0 revert m\u1ed9t commit merge (commit \u0111\u01b0\u1ee3c t\u1ea1o ra trong qu\u00e1 tr\u00ecnh merge). B\u1edfi v\u00ec commit merge li\u00ean quan \u0111\u1ebfn nhi\u1ec1u nh\u00e1nh v\u00e0 nhi\u1ec1u commit, n\u00ean vi\u1ec7c revert n\u00f3 c\u0169ng ph\u1ee9c t\u1ea1p h\u01a1n. B\u1ea1n c\u1ea7n ph\u1ea3i x\u00e1c \u0111\u1ecbnh nh\u00e1nh ch\u00ednh c\u1ea7n \u0111\u01b0\u1ee3c gi\u1eef l\u1ea1i:<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span style=\"font-weight: 400;\">git revert -m &lt;parent-number&gt; &lt;merge-commit-hash&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;\"><code>-m &lt;parent-number&gt;<\/code>: Ch\u1ec9 \u0111\u1ecbnh nh\u00e1nh ch\u00ednh (parent branch). Th\u01b0\u1eddng l\u00e0 1, t\u01b0\u01a1ng \u1ee9ng v\u1edbi nh\u00e1nh b\u1ea1n \u0111ang l\u00e0m vi\u1ec7c tr\u01b0\u1edbc khi merge.<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\"><code>&lt;merge-commit-hash&gt;<\/code>: Hash c\u1ee7a commit merge m\u00e0 b\u1ea1n mu\u1ed1n ho\u00e0n t\u00e1c.<\/span><\/li>\n<\/ul>\n\n\n\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5, b\u1ea1n c\u00f3 m\u1ed9t nh\u00e1nh feat \u0111\u00e3 \u0111\u01b0\u1ee3c merge v\u00e0o nh\u00e1nh develop v\u1edbi l\u1ecbch s\u1eed commit nh\u01b0 sau:<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span style=\"font-weight: 400;\">* xe25f7g9 (merge commit) Merge branch <\/span><span style=\"font-weight: 400;\">'feat'<\/span><span style=\"font-weight: 400;\"> into develop<\/span>\n<span style=\"font-weight: 400;\">|\\<\/span>\n<span style=\"font-weight: 400;\">| * b3a2s1d4 (feat) Th\u00eam t\u1eadp tin 1<\/span>\n<span style=\"font-weight: 400;\">| * c3d4e5f6 (feat) Th\u00eam ch\u1ee9c n\u0103ng t\u00ecm ki\u1ebfm<\/span>\n<span style=\"font-weight: 400;\">|\/<\/span>\n<span style=\"font-weight: 400;\">* b2c2f4e6 (develop) C\u1eadp nh\u1eadt giao di\u1ec7n ch\u00ednh<\/span><\/code><\/pre>\n\n\n\n<p><span style=\"font-weight: 400;\">L\u00fac n\u00e0y, b\u1ea1n \u0111ang \u0111\u1ee9ng \u1edf nh\u00e1nh develop v\u00e0 mu\u1ed1n ho\u00e0n t\u00e1c commit merge:<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span style=\"font-weight: 400;\">git revert -m 1 xe25f7g9<\/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;\"><code>-m 1<\/code>: Ch\u1ec9 \u0111\u1ecbnh nh\u00e1nh develop l\u00e0 nh\u00e1nh ch\u00ednh c\u1ea7n gi\u1eef l\u1ea1i.<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">xe25f7g9: L\u00e0 hash c\u1ee7a commit merge c\u1ea7n ho\u00e0n t\u00e1c.<\/span><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-nh\u1eefng-l\u01b0u-y-khi-s\u1eed-d\u1ee5ng-git-revert\"><span class=\"ez-toc-section\" id=\"Nhung_luu_y_khi_su_dung_git_revert\"><\/span><b>Nh\u1eefng l\u01b0u \u00fd khi s\u1eed d\u1ee5ng git revert<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><span style=\"font-weight: 400;\">\u0110\u1ec3 vi\u1ec7c s\u1eed d\u1ee5ng git revert \u0111\u01b0\u1ee3c hi\u1ec7u qu\u1ea3, b\u1ea1n c\u1ea7n l\u01b0u \u00fd m\u1ed9t s\u1ed1 \u0111i\u1ec3m sau:<\/span><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span style=\"font-weight: 400;\">Kh\u00f4ng n\u00ean ho\u00e0n t\u00e1c c\u00e1c commit c\u1ee5c b\u1ed9 ch\u01b0a \u0111\u01b0\u1ee3c \u0111\u1ea9y l\u00ean kho l\u01b0u tr\u1eef t\u1eeb xa: Git revert n\u00ean \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng khi commit \u0111\u00e3 \u0111\u01b0\u1ee3c \u0111\u1ea9y l\u00ean kho l\u01b0u tr\u1eef t\u1eeb xa v\u00e0 ng\u01b0\u1eddi kh\u00e1c c\u00f3 th\u1ec3 \u0111\u00e3 k\u00e9o commit v\u1ec1 m\u00e1y c\u00e1 nh\u00e2n. C\u00f2n tr\u01b0\u1eddng h\u1ee3p commit ch\u1ec9 \u1edf kho c\u1ee5c b\u1ed9, b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng git reset \u0111\u1ec3 thay th\u1ebf. \u0110i\u1ec1u n\u00e0y tr\u00e1nh vi\u1ec7c t\u1ea1o ra nhi\u1ec1u commit d\u01b0 th\u1eeba.<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">L\u1ef1a ch\u1ecdn \u0111\u00fang nh\u00e1nh ch\u00ednh khi revert commit merge: Khi revert m\u1ed9t commit merge, b\u1ea1n c\u1ea7n l\u01b0u \u00fd ch\u1ecdn \u0111\u00fang nh\u00e1nh ch\u00ednh c\u1ea7n gi\u1eef l\u1ea1i. \u0110i\u1ec1u n\u00e0y gi\u00fap tr\u00e1nh d\u1eabn \u0111\u1ebfn sai l\u1ec7ch trong l\u1ecbch s\u1eed.<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">X\u1eed l\u00fd xung \u0111\u1ed9t khi revert: Khi th\u1ef1c hi\u1ec7n revert m\u1ed9t commit l\u1edbn c\u00f3 th\u1ec3 x\u1ea3y ra xung \u0111\u1ed9t. B\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng c\u00e1c option \u0111\u1ec3 gi\u1ea3i quy\u1ebft xung \u0111\u1ed9t nh\u01b0:<\/span>\n<ul class=\"wp-block-list\">\n<li><span style=\"font-weight: 400;\"><code>git revert --continue<\/code>: ti\u1ebfp t\u1ee5c qu\u00e1 tr\u00ecnh revert sau khi gi\u1ea3i quy\u1ebft xung \u0111\u1ed9t<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\"><code>git revert --abort<\/code>: ho\u00e0n t\u00e1c qu\u00e1 tr\u00ecnh revert<\/span><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-so-sanh-git-revert-va-git-reset\"><span class=\"ez-toc-section\" id=\"So_sanh_git_revert_va_git_reset\"><\/span><b>So s\u00e1nh git revert v\u00e0 git reset<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><span style=\"font-weight: 400;\">Git revert v\u00e0 git reset \u0111\u1ec1u \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 ho\u00e0n t\u00e1c c\u00e1c thay \u0111\u1ed5i \u0111\u00e3 \u0111\u01b0\u1ee3c commit, tuy nhi\u00ean gi\u1eefa ch\u00fang c\u00f3 nh\u1eefng c\u01a1 ch\u1ebf ho\u1ea1t \u0111\u1ed9ng v\u00e0 m\u1ee5c \u0111\u00edch s\u1eed d\u1ee5ng kh\u00e1c nhau.<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">D\u01b0\u1edbi \u0111\u00e2y l\u00e0 b\u1ea3n 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 revert<\/b><\/td><td><b>Git reset<\/b><\/td><\/tr><tr><td><b>C\u01a1 ch\u1ebf<\/b><\/td><td><span style=\"font-weight: 400;\">T\u1ea1o commit \u0111\u1ea3o ng\u01b0\u1ee3c<\/span><\/td><td><span style=\"font-weight: 400;\">X\u00f3a commit kh\u1ecfi l\u1ecbch s\u1eed<\/span><\/td><\/tr><tr><td><b>T\u00e1c \u0111\u1ed9ng \u0111\u1ebfn l\u1ecbch s\u1eed commit<\/b><\/td><td><span style=\"font-weight: 400;\">Kh\u00f4ng thay \u0111\u1ed5i l\u1ecbch s\u1eed commit<\/span><\/td><td><span style=\"font-weight: 400;\">C\u00f3 th\u1ec3 thay \u0111\u1ed5i l\u1ecbch s\u1eed<\/span><\/td><\/tr><tr><td><b>C\u1ed9ng t\u00e1c nh\u00f3m<\/b><\/td><td><span style=\"font-weight: 400;\">\u0110\u1ea3m b\u1ea3o an to\u00e0n v\u00e0 h\u1ea1n ch\u1ebf x\u1ea3y ra xung \u0111\u1ed9t m\u00e3 ngu\u1ed3n<\/span><\/td><td><span style=\"font-weight: 400;\">C\u00f3 kh\u1ea3 n\u0103ng cao x\u1ea3y ra xung \u0111\u1ed9t m\u00e3 ngu\u1ed3n<\/span><\/td><\/tr><tr><td><b>Kh\u1ea3 n\u0103ng ph\u1ee5c h\u1ed3i<\/b><\/td><td><span style=\"font-weight: 400;\">C\u00f3 th\u1ec3 ph\u1ee5c h\u1ed3i h\u00e0nh \u0111\u1ed9ng d\u1ec5 d\u00e0ng<\/span><\/td><td><span style=\"font-weight: 400;\">Kh\u00f3 ph\u1ee5c h\u1ed3i v\u00e0 c\u00f3 kh\u1ea3 n\u0103ng m\u1ea5t d\u1eef li\u1ec7u n\u1ebfu s\u1eed d\u1ee5ng sai<\/span><\/td><\/tr><tr><td><b>Tr\u01b0\u1eddng h\u1ee3p s\u1eed d\u1ee5ng<\/b><\/td><td><span style=\"font-weight: 400;\">1. Ho\u00e0n t\u00e1c commit nh\u01b0ng v\u1eabn gi\u1eef l\u1ecbch s\u1eed commit kh\u00f4ng b\u1ecb thay \u0111\u1ed5i<\/span><br><p><span style=\"font-weight: 400;\">2. N\u1ed9i dung commit c\u1ea7n ho\u00e0n t\u00e1c \u0111\u00e3 \u0111\u01b0\u1ee3c \u0111\u1ea9y l\u00ean remote repository, vi\u1ec7c thay \u0111\u1ed5i l\u1ecbch s\u1eed l\u00fac n\u00e0y l\u00e0 kh\u00f4ng an to\u00e0n<\/span><\/p><\/td><td><span style=\"font-weight: 400;\">1. Khi c\u1ea7n ho\u00e0n t\u00e1c commit \u1edf kho l\u01b0u tr\u1eef c\u1ee5c b\u1ed9 m\u00e0 kh\u00f4ng mu\u1ed1n commit c\u0169 c\u00f2n l\u01b0u tr\u1eef trong l\u1ecbch s\u1eed<\/span><br><p><span style=\"font-weight: 400;\">2. Tr\u01b0\u1eddng h\u1ee3p d\u1eef li\u1ec7u commit ch\u01b0a \u0111\u01b0\u1ee3c \u0111\u1ea9y l\u00ean remote repository v\u00e0 b\u1ea1n mu\u1ed1n lo\u1ea1i b\u1ecf nh\u1eefng commit nh\u1ecf l\u1ebb<\/span><\/p><\/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-reset-la-gi\/\" target=\"_blank\" rel=\"noopener\"><strong>H\u01b0\u1edbng d\u1eabn c\u00e1ch x\u00f3a b\u1ecf commit b\u1eb1ng Git Reset<\/strong><\/a><\/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-revert\"><span class=\"ez-toc-section\" id=\"Cac_cau_hoi_thuong_gap_ve_git_revert\"><\/span><strong>C\u00e1c c\u00e2u h\u1ecfi th\u01b0\u1eddng g\u1eb7p v\u1ec1 git revert<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-nh\u1eefng-tr\u01b0\u1eddng-h\u1ee3p-nao-nen-s\u1eed-d\u1ee5ng-git-revert\"><b>Nh\u1eefng tr\u01b0\u1eddng h\u1ee3p n\u00e0o n\u00ean s\u1eed d\u1ee5ng git revert?<\/b><\/h3>\n\n\n\n<p><span style=\"font-weight: 400;\">B\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng git revert \u0111\u00e3 ho\u00e0n t\u00e1c c\u00e1c thay \u0111\u1ed5i \u0111\u00e3 \u0111\u01b0\u1ee3c commit, v\u00e0 \u0111\u1eb7c bi\u1ec7t l\u00e0 trong nh\u1eefng tr\u01b0\u1eddng h\u1ee3p:<\/span><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span style=\"font-weight: 400;\">Kh\u00f4ng mu\u1ed1n l\u00e0m thay \u0111\u1ed5i l\u1ecbch s\u1eed commit<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">Commit \u0111\u00e3 \u0111\u01b0\u1ee3c \u0111\u1ea9y l\u00ean kho t\u1eeb xa v\u00e0 ng\u01b0\u1eddi kh\u00e1c \u0111\u00e3 k\u00e9o commit v\u1ec1 m\u00e1y<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\">Ho\u00e0n t\u00e1c c\u00e1c commit merge<\/span><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-toi-co-th\u1ec3-revert-cung-luc-nhi\u1ec1u-commit-khong\"><b>T\u00f4i c\u00f3 th\u1ec3 revert c\u00f9ng l\u00fac nhi\u1ec1u commit kh\u00f4ng?<\/b><\/h3>\n\n\n\n<p><span style=\"font-weight: 400;\">B\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng revert \u0111\u1ec3 ho\u00e0n t\u00e1c c\u00f9ng l\u00fac nhi\u1ec1u commits. C\u00f3 hai c\u00e1ch ph\u1ed5 bi\u1ebfn \u0111\u1ec3 l\u00e0m \u0111i\u1ec1u n\u00e0y:<\/span><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-s\u1eed-d\u1ee5ng-ph\u1ea1m-vi-commit\"><strong>S\u1eed d\u1ee5ng ph\u1ea1m vi commit<\/strong><\/h4>\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 revert &lt;oldest-commit&gt;..&lt;latest-commit&gt;<\/span><\/code><\/pre>\n\n\n\n<p><span style=\"font-weight: 400;\">Gi\u1ea3i th\u00edch:<\/span><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span style=\"font-weight: 400;\"><code>oldest-commit<\/code>: Commit c\u0169 nh\u1ea5t m\u00e0 b\u1ea1n mu\u1ed1n revert.<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\"><code>latest-commit<\/code>: Commit m\u1edbi nh\u1ea5t s\u1ebd \u0111\u01b0\u1ee3c revert.<\/span><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-li\u1ec7t-ke-danh-sach-commit\"><strong>Li\u1ec7t k\u00ea danh s\u00e1ch commit<\/strong><\/h4>\n\n\n\n<p><span style=\"font-weight: 400;\">Li\u1ec7t k\u00ea c\u00e1c commit hash c\u1ee7a nh\u1eefng commits m\u00e0 b\u1ea1n mu\u1ed1n revert, Git s\u1ebd t\u1ea1o commit ng\u01b0\u1ee3c cho t\u1eebng commit \u0111\u01b0\u1ee3c ch\u1ec9 \u0111\u1ecbnh. C\u00fa ph\u00e1p:<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span style=\"font-weight: 400;\">git revert &lt;commit-hash1&gt; &lt;commit-hash2&gt; ... &lt;commit-hashN&gt;<\/span><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-lam-sao-d\u1ec3-hoan-tac-hanh-d\u1ed9ng-revert\"><b>L\u00e0m sao \u0111\u1ec3 ho\u00e0n t\u00e1c h\u00e0nh \u0111\u1ed9ng revert?<\/b><\/h3>\n\n\n\n<p><span style=\"font-weight: 400;\">Git revert s\u1ebd t\u1ea1o ra m\u1ed9t commit \u0111\u1ea3o ng\u01b0\u1ee3c so v\u1edbi commit \u0111\u01b0\u1ee3c revert. V\u00ec v\u1eady \u0111\u1ec3 ho\u00e0n t\u00e1c m\u1ed9t h\u00e0nh \u0111\u1ed9ng revert, ch\u00ednh l\u00e0 ho\u00e0n t\u00e1c commit \u0111\u1ea3o ng\u01b0\u1ee3c \u0111\u00f3. L\u00fac n\u00e0y ch\u00fang ta c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng l\u1ea1i ch\u00ednh git revert ho\u1eb7c git reset \u0111\u1ec3 th\u1ef1c hi\u1ec7n \u0111i\u1ec1u n\u00e0y.<\/span><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span style=\"font-weight: 400;\"><strong>Git revert<\/strong>: B\u1ea1n c\u00f3 th\u1ec3 th\u1ef1c hi\u1ec7n h\u00e0nh \u0111\u1ed9ng revert th\u00eam m\u1ed9t l\u1ea7n n\u1eefa. L\u00fac n\u00e0y n\u00f3 s\u1ebd c\u00f3 d\u1ea1ng l\u00e0 \u201crevert c\u1ee7a revert\u201d. Git s\u1ebd t\u1ea1o ra m\u1ed9t commit \u0111\u1ec3 \u0111\u1ea3o ng\u01b0\u1ee3c commit revert tr\u01b0\u1edbc \u0111\u00f3.<\/span><\/li>\n\n\n\n<li><span style=\"font-weight: 400;\"><strong>Git reset<\/strong>: Tr\u01b0\u1eddng h\u1ee3p h\u00e0nh \u0111\u1ed9ng revert tr\u01b0\u1edbc \u0111\u00f3 v\u1eabn ch\u01b0a \u0111\u01b0\u1ee3c \u0111\u1ea9y l\u00ean remote repository, b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng git reset \u0111\u1ec3 lo\u1ea1i b\u1ecf commit revert \u0111\u00f3 v\u00e0 tr\u1ea3 l\u1ea1i tr\u1ea1ng th\u00e1i ban \u0111\u1ea7u cho repository.<\/span><\/li>\n<\/ul>\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;\">Ho\u00e0n t\u00e1c m\u1ed9t commit l\u00e0 \u0111i\u1ec1u kh\u00f3 tr\u00e1nh kh\u1ecfi trong qu\u00e1 tr\u00ecnh ph\u00e1t tri\u1ec3n ph\u1ea7n m\u1ec1m. V\u00ec v\u1eady, vi\u1ec7c th\u00e0nh th\u1ea1o l\u1ec7nh git revert s\u1ebd gi\u00fap b\u1ea1n l\u00e0m vi\u1ec7c v\u1edbi m\u00e3 ngu\u1ed3n hi\u1ec7u qu\u1ea3 v\u00e0 an to\u00e0n h\u01a1n.<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">ITviec hy v\u1ecdng b\u00e0i vi\u1ebft n\u00e0y \u0111\u00e3 gi\u00fap b\u1ea1n hi\u1ec3u r\u00f5 c\u00e1ch ho\u1ea1t \u0111\u1ed9ng c\u1ee7a git revert, \u0111\u1ed3ng th\u1eddi cung c\u1ea5p nh\u1eefng ki\u1ebfn th\u1ee9c h\u1eefu \u00edch \u0111\u1ec3 \u00e1p d\u1ee5ng l\u1ec7nh n\u00e0y trong qu\u00e1 tr\u00ecnh ph\u00e1t tri\u1ec3n ph\u1ea7n m\u1ec1m c\u1ee7a b\u1ea1n.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Trong qu\u00e1 tr\u00ecnh ph\u00e1t tri\u1ec3n ph\u1ea7n m\u1ec1m, vi\u1ec7c m\u1eafc ph\u1ea3i sai l\u1ea7m nh\u01b0 thay \u0111\u1ed5i nh\u1eefng n\u1ed9i dung kh\u00f4ng ch\u00ednh x\u00e1c ho\u1eb7c g\u00e2y ra l\u1ed7i h\u1ec7 th\u1ed1ng trong c\u00e1c commit code l\u00e0 \u0111i\u1ec1u kh\u00f4ng th\u1ec3 tr\u00e1nh kh\u1ecfi. Git cung c\u1ea5p m\u1ed9t c\u00f4ng c\u1ee5 m\u1ea1nh m\u1ebd \u0111\u1ec3 gi\u00fap l\u1eadp tr\u00ecnh vi\u00ean ho\u00e0n t\u00e1c nh\u1eefng thay \u0111\u1ed5i [&hellip;]<\/p>\n","protected":false},"author":235,"featured_media":83616,"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-83250","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.7) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Git revert: H\u01b0\u1edbng d\u1eabn c\u00e1ch ho\u00e0n t\u00e1c l\u1ecbch s\u1eed b\u1eb1ng Git Revert - ITviec Blog<\/title>\n<meta name=\"description\" content=\"Git revert l\u00e0 m\u1ed9t l\u1ec7nh trong Git \u0111\u1ec3 ho\u00e0n t\u00e1c (undo) c\u00e1c thay \u0111\u1ed5i trong commit tr\u01b0\u1edbc \u0111\u00f3. Chi ti\u1ebft c\u01a1 ch\u1ebf ho\u1ea1t \u0111\u1ed9ng, c\u00e1ch s\u1eed d\u1ee5ng Git Revert.\" \/>\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-revert-la-gi\/\" \/>\n<meta property=\"og:locale\" content=\"vi_VN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Git revert: H\u01b0\u1edbng d\u1eabn c\u00e1ch ho\u00e0n t\u00e1c l\u1ecbch s\u1eed b\u1eb1ng Git Revert\" \/>\n<meta property=\"og:description\" content=\"Trong qu\u00e1 tr\u00ecnh ph\u00e1t tri\u1ec3n ph\u1ea7n m\u1ec1m, vi\u1ec7c m\u1eafc ph\u1ea3i sai l\u1ea7m nh\u01b0 thay \u0111\u1ed5i nh\u1eefng n\u1ed9i dung kh\u00f4ng ch\u00ednh x\u00e1c ho\u1eb7c g\u00e2y ra l\u1ed7i h\u1ec7 th\u1ed1ng trong c\u00e1c commit code l\u00e0\" \/>\n<meta property=\"og:url\" content=\"https:\/\/itviec.com\/blog\/git-revert-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-30T10:46:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-07-10T03:48:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/Git-Revert-1-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=\"10 ph\u00fat\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Git revert: H\u01b0\u1edbng d\u1eabn c\u00e1ch ho\u00e0n t\u00e1c l\u1ecbch s\u1eed b\u1eb1ng Git Revert - ITviec Blog","description":"Git revert l\u00e0 m\u1ed9t l\u1ec7nh trong Git \u0111\u1ec3 ho\u00e0n t\u00e1c (undo) c\u00e1c thay \u0111\u1ed5i trong commit tr\u01b0\u1edbc \u0111\u00f3. Chi ti\u1ebft c\u01a1 ch\u1ebf ho\u1ea1t \u0111\u1ed9ng, c\u00e1ch s\u1eed d\u1ee5ng Git Revert.","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-revert-la-gi\/","og_locale":"vi_VN","og_type":"article","og_title":"Git revert: H\u01b0\u1edbng d\u1eabn c\u00e1ch ho\u00e0n t\u00e1c l\u1ecbch s\u1eed b\u1eb1ng Git Revert","og_description":"Trong qu\u00e1 tr\u00ecnh ph\u00e1t tri\u1ec3n ph\u1ea7n m\u1ec1m, vi\u1ec7c m\u1eafc ph\u1ea3i sai l\u1ea7m nh\u01b0 thay \u0111\u1ed5i nh\u1eefng n\u1ed9i dung kh\u00f4ng ch\u00ednh x\u00e1c ho\u1eb7c g\u00e2y ra l\u1ed7i h\u1ec7 th\u1ed1ng trong c\u00e1c commit code l\u00e0","og_url":"https:\/\/itviec.com\/blog\/git-revert-la-gi\/","og_site_name":"ITviec Blog","article_publisher":"https:\/\/www.facebook.com\/ITviec","article_published_time":"2024-12-30T10:46:49+00:00","article_modified_time":"2025-07-10T03:48:30+00:00","og_image":[{"width":1500,"height":790,"url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/Git-Revert-1-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":"10 ph\u00fat"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/itviec.com\/blog\/git-revert-la-gi\/#article","isPartOf":{"@id":"https:\/\/itviec.com\/blog\/git-revert-la-gi\/"},"author":{"name":"Ph\u1ea1m H\u1eefu Ng\u1ecdc","@id":"https:\/\/itviec.com\/blog\/#\/schema\/person\/407769a7625b7f955cef615f7a99abad"},"headline":"Git revert: H\u01b0\u1edbng d\u1eabn c\u00e1ch ho\u00e0n t\u00e1c l\u1ecbch s\u1eed b\u1eb1ng Git Revert","datePublished":"2024-12-30T10:46:49+00:00","dateModified":"2025-07-10T03:48:30+00:00","mainEntityOfPage":{"@id":"https:\/\/itviec.com\/blog\/git-revert-la-gi\/"},"wordCount":2329,"publisher":{"@id":"https:\/\/itviec.com\/blog\/#organization"},"image":{"@id":"https:\/\/itviec.com\/blog\/git-revert-la-gi\/#primaryimage"},"thumbnailUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/Git-Revert-1-vippro.jpg","articleSection":["Chuy\u00ean m\u00f4n IT"],"inLanguage":"vi"},{"@type":"WebPage","@id":"https:\/\/itviec.com\/blog\/git-revert-la-gi\/","url":"https:\/\/itviec.com\/blog\/git-revert-la-gi\/","name":"Git revert: H\u01b0\u1edbng d\u1eabn c\u00e1ch ho\u00e0n t\u00e1c l\u1ecbch s\u1eed b\u1eb1ng Git Revert - ITviec Blog","isPartOf":{"@id":"https:\/\/itviec.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/itviec.com\/blog\/git-revert-la-gi\/#primaryimage"},"image":{"@id":"https:\/\/itviec.com\/blog\/git-revert-la-gi\/#primaryimage"},"thumbnailUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/Git-Revert-1-vippro.jpg","datePublished":"2024-12-30T10:46:49+00:00","dateModified":"2025-07-10T03:48:30+00:00","description":"Git revert l\u00e0 m\u1ed9t l\u1ec7nh trong Git \u0111\u1ec3 ho\u00e0n t\u00e1c (undo) c\u00e1c thay \u0111\u1ed5i trong commit tr\u01b0\u1edbc \u0111\u00f3. Chi ti\u1ebft c\u01a1 ch\u1ebf ho\u1ea1t \u0111\u1ed9ng, c\u00e1ch s\u1eed d\u1ee5ng Git Revert.","breadcrumb":{"@id":"https:\/\/itviec.com\/blog\/git-revert-la-gi\/#breadcrumb"},"inLanguage":"vi","potentialAction":[{"@type":"ReadAction","target":["https:\/\/itviec.com\/blog\/git-revert-la-gi\/"]}]},{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/git-revert-la-gi\/#primaryimage","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/Git-Revert-1-vippro.jpg","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/Git-Revert-1-vippro.jpg","width":1500,"height":790},{"@type":"BreadcrumbList","@id":"https:\/\/itviec.com\/blog\/git-revert-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 revert: H\u01b0\u1edbng d\u1eabn c\u00e1ch ho\u00e0n t\u00e1c l\u1ecbch s\u1eed b\u1eb1ng Git Revert"}]},{"@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\/83250","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=83250"}],"version-history":[{"count":2,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/83250\/revisions"}],"predecessor-version":[{"id":89230,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/83250\/revisions\/89230"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/media\/83616"}],"wp:attachment":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/media?parent=83250"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/categories?post=83250"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/tags?post=83250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}