{"id":190,"date":"2026-01-04T07:52:30","date_gmt":"2026-01-04T07:52:30","guid":{"rendered":"https:\/\/blogs.giamkichsan.com\/?p=190"},"modified":"2026-01-04T07:52:36","modified_gmt":"2026-01-04T07:52:36","slug":"cac-cau-lenh-trong-git","status":"publish","type":"post","link":"https:\/\/blogs.giamkichsan.com\/index.php\/2026\/01\/04\/cac-cau-lenh-trong-git\/","title":{"rendered":"C\u00e1c c\u00e2u l\u1ec7nh trong git"},"content":{"rendered":"\n<ol class=\"wp-block-list\">\n<li><strong>CHI TI\u1ebeT t\u1eebng b\u01b0\u1edbc<\/strong> REVERT cho tr\u01b0\u1eddng h\u1ee3p <strong>\u0111\u00e3 merge v\u00e0 \u0111\u00e3 push l\u00ean GitHub server<\/strong><\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udd39 B\u01b0\u1edbc 1: Checkout v\u00e0o branch \u0111\u00e3 b\u1ecb merge<\/h2>\n\n\n\n<p>V\u00ed d\u1ee5 merge v\u00e0o <code>main<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git checkout main\ngit pull\n<\/code><\/pre>\n\n\n\n<p>\ud83d\udccc \u0110\u1ea3m b\u1ea3o b\u1ea1n \u0111ang \u1edf <strong>branch \u0111\u00fang<\/strong> v\u00e0 <strong>code m\u1edbi nh\u1ea5t<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udd39 B\u01b0\u1edbc 2: T\u00ecm merge commit<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>git log --oneline\n<\/code><\/pre>\n\n\n\n<p>B\u1ea1n s\u1ebd th\u1ea5y d\u1ea1ng nh\u01b0:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>a1b2c3d Merge branch 'feature\/login' into main\n<\/code><\/pre>\n\n\n\n<p>\ud83d\udc49 <strong>Copy hash<\/strong> (<code>a1b2c3d<\/code>)<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udd39 B\u01b0\u1edbc 3: Revert merge commit<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>git revert -m 1 a1b2c3d\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udccc Gi\u1ea3i th\u00edch <code>-m 1<\/code><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>1<\/code> = gi\u1eef branch <strong>main<\/strong><\/li>\n\n\n\n<li>undo to\u00e0n b\u1ed9 thay \u0111\u1ed5i t\u1eeb branch \u0111\u01b0\u1ee3c merge v\u00e0o<\/li>\n<\/ul>\n\n\n\n<p>\u26a0\ufe0f <strong>B\u1eaeT BU\u1ed8C ph\u1ea3i c\u00f3 <code>-m<\/code> khi revert merge<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udd39 B\u01b0\u1edbc 4: Resolve conflict (n\u1ebfu c\u00f3)<\/h2>\n\n\n\n<p>N\u1ebfu Git b\u00e1o conflict:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git status\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>M\u1edf file b\u1ecb conflict<\/li>\n\n\n\n<li>S\u1eeda<\/li>\n\n\n\n<li>Sau \u0111\u00f3:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>git add .\ngit revert --continue\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udd39 B\u01b0\u1edbc 5: Push l\u00ean GitHub<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>git push\n<\/code><\/pre>\n\n\n\n<p>\ud83c\udf89 Xong! Merge \u0111\u00e3 \u0111\u01b0\u1ee3c undo an to\u00e0n<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\u2705 K\u1ebft qu\u1ea3 b\u1ea1n s\u1ebd th\u1ea5y<\/h1>\n\n\n\n<ul class=\"wp-block-list\">\n<li>GitHub c\u00f3 <strong>commit m\u1edbi<\/strong> d\u1ea1ng: <code>Revert \"Merge branch 'feature\/login' into main\"<\/code><\/li>\n\n\n\n<li>Code quay v\u1ec1 tr\u1ea1ng th\u00e1i <strong>tr\u01b0\u1edbc khi merge<\/strong><\/li>\n\n\n\n<li>L\u1ecbch s\u1eed v\u1eabn r\u00f5 r\u00e0ng \ud83d\udc4c<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\udfe2 C\u00e1ch kh\u00e1c (n\u1ebfu merge b\u1eb1ng Pull Request)<\/h1>\n\n\n\n<p>\ud83d\udc49 V\u00e0o <strong>Pull Request \u0111\u00e3 merge<\/strong><br>\ud83d\udc49 B\u1ea5m <strong>Revert<\/strong><br>\ud83d\udc49 GitHub t\u1ef1 t\u1ea1o PR undo<\/p>\n\n\n\n<p>\u2714\ufe0f Kh\u00f4ng c\u1ea7n terminal<br>\u2714\ufe0f R\u1ea5t an to\u00e0n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><\/h2>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>\ud83d\udd39 B\u01b0\u1edbc 1: Checkout v\u00e0o branch \u0111\u00e3 b\u1ecb merge V\u00ed d\u1ee5 merge v\u00e0o main: \ud83d\udccc \u0110\u1ea3m b\u1ea3o b\u1ea1n \u0111ang \u1edf branch \u0111\u00fang v\u00e0 code m\u1edbi <a class=\"mh-excerpt-more\" href=\"https:\/\/blogs.giamkichsan.com\/index.php\/2026\/01\/04\/cac-cau-lenh-trong-git\/\" title=\"C\u00e1c c\u00e2u l\u1ec7nh trong git\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-190","post","type-post","status-publish","format-standard","hentry","category-ubuntu-he-dieu-hanh"],"_links":{"self":[{"href":"https:\/\/blogs.giamkichsan.com\/index.php\/wp-json\/wp\/v2\/posts\/190","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.giamkichsan.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.giamkichsan.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.giamkichsan.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.giamkichsan.com\/index.php\/wp-json\/wp\/v2\/comments?post=190"}],"version-history":[{"count":1,"href":"https:\/\/blogs.giamkichsan.com\/index.php\/wp-json\/wp\/v2\/posts\/190\/revisions"}],"predecessor-version":[{"id":191,"href":"https:\/\/blogs.giamkichsan.com\/index.php\/wp-json\/wp\/v2\/posts\/190\/revisions\/191"}],"wp:attachment":[{"href":"https:\/\/blogs.giamkichsan.com\/index.php\/wp-json\/wp\/v2\/media?parent=190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.giamkichsan.com\/index.php\/wp-json\/wp\/v2\/categories?post=190"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.giamkichsan.com\/index.php\/wp-json\/wp\/v2\/tags?post=190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}