๐Ÿ•ท๏ธ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 46 (from laksa148)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

โ„น๏ธ Skipped - page is already crawled

๐Ÿ“„
INDEXABLE
โœ…
CRAWLED
4 days ago
๐Ÿค–
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0.2 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://linuxhandbook.com/git-move-commit-branch/
Last Crawled2026-04-13 02:28:58 (4 days ago)
First Indexed2024-06-28 15:18:11 (1 year ago)
HTTP Status Code200
Meta TitleHow to Move Commit to Another Git Branch
Meta DescriptionMade a commit to an incorrect branch and now you want to move the commit to the correct branch? Here's how to handle this git situation.
Meta Canonicalnull
Boilerpipe Text
Sh(g)it happens. I mean it is usual to clone the main branch, create or switch to a dev branch and then commit the changes to this dev branch which is merged to the main later. Imagine you follow the same only you forget to switch to the dev branch and you made the commit to the main branch. But before pushing, you want to move this commit to the dev branch instead. You should also remove the commit from the main vranch. Let me help you by showing the steps for: Moving the commit to the correct branch Reverting the commit from the incorrect branch Moving commit to another branch First, let's address the issue that I encountered: While working with three branches, I was supposed to make one commit to the header branch and another to the footer branch. The first commit to the header branch was correct but unfortunately, I made the second commit to the header branch instead of the footer branch: When I checked the git log, it was pretty clear to me that I made a commit to the wrong branch: Now, let's take a look at the steps to move the commit to another branch. Step 1: Find the hash of the commit To find the hash of the commit you want to move, you can use the git log in the beach where you made a wrong commit. I made a wrong commit in the head branch so I'll be using git log there: git log Once you find the hash, copy the hash. Step 2: Switch to the target branch Next, switch the branch in which you want to move the commit. For that purpose, you can use the git checkout command: git checkout <branch-name> In my case, I want to move to commit to the footer beach, so I'll be using the following: git checkout footer Step 3: Move the commit to the target branch Once you switch to the target branch, use the git cherry-pick command along with the hash you copied from the first step: git cherry-pick <hash> To verify if the commit was moved or not, you can check the git log: git log There you go! Revert the incorrect commit When you use the cherry-pick command, it does not move the commit but copies the commit to the current branch. So you are still left with the incorrect commit on the first branch. The solution is to revert the incorrect commit . For that, first switch to the branch in which you made the incorrect commit: git checkout <branch-name> In my case, the beach name was header so I will be using the following: git checkout header Now, if you check the git log, you will still find the incorrect commit which you recently moved using the git cherry-pick command: To revert this commit, you append the hash of the target commit to the git revert command as shown here: git revert <hash> It will open the text editor telling you it is reverting the commit. It creates another commit without those changes resulting removal of the specified commit. Close the text editor and that's it: Once you close the text editor, you will see an output telling you that the commit has been deleted: There you have it! Wrapping Up In this tutorial, I went through how you can move your commit to a different branch and also explained how you can remove the incorrect commit. I hope you will find this guide helpful. If you have any queries, feel free to leave us a comment.
Markdown
[Skip to main content](https://linuxhandbook.com/git-move-commit-branch/#sx-main) [![Linux Handbook](https://linuxhandbook.com/content/images/2021/08/linux-handbook-cover.png)](https://linuxhandbook.com/) - [๐Ÿ“š Books](https://linuxhandbook.com/ebooks/) - [๐ŸŽ“ Courses](https://linuxhandbook.com/courses/) - [๐Ÿ‘ฉโ€๐Ÿ’ป Resources](https://linuxhandbook.com/learning-corner/) - [โœจ Latest Tips and Tutorials](https://linuxhandbook.com/blog/) - [๐Ÿ“ฌ Newsletter](https://linuxhandbook.com/newsletter/) - [๐Ÿชช Who we are?](https://linuxhandbook.com/about/) - - [๐Ÿ“š Books](https://linuxhandbook.com/ebooks/) [๐ŸŽ“ Courses](https://linuxhandbook.com/courses/) [๐Ÿ‘ฉโ€๐Ÿ’ป Resources](https://linuxhandbook.com/learning-corner/) [โœจ Latest Tips and Tutorials](https://linuxhandbook.com/blog/) [๐Ÿ“ฌ Newsletter](https://linuxhandbook.com/newsletter/) [๐Ÿชช Who we are?](https://linuxhandbook.com/about/) Sign In Subscribe / - [๐Ÿ“š Books](https://linuxhandbook.com/ebooks/) - [๐ŸŽ“ Courses](https://linuxhandbook.com/courses/) - [๐Ÿ‘ฉโ€๐Ÿ’ป Resources](https://linuxhandbook.com/learning-corner/) - [โœจ Latest Tips and Tutorials](https://linuxhandbook.com/blog/) - [๐Ÿ“ฌ Newsletter](https://linuxhandbook.com/newsletter/) - [๐Ÿชช Who we are?](https://linuxhandbook.com/about/) - Sign In - - [How to Undo a Commit in Git](https://linuxhandbook.com/git-undo-commit/) - [How to Delete Local Git Branch](https://linuxhandbook.com/git-delete-branch-local/) - [How to Delete Remote Git Branch](https://linuxhandbook.com/git-delete-branch-remote/) - [Create a New Branch in Git](https://linuxhandbook.com/git-create-branch/) - [Setup Username and Email in Git](https://linuxhandbook.com/git-set-username-email/) - [How to Unstage Files in Git](https://linuxhandbook.com/git-unstage/) - [Switching Branches in Git](https://linuxhandbook.com/git-switch-branch/) - [Clean Your Git Repository With Git Clean](https://linuxhandbook.com/git-clean/) - [What is the .git folder?](https://linuxhandbook.com/dot-git-folder/) - [Undo Git Add and Remove Files from Staging](https://linuxhandbook.com/git-undo-add/) - [Git Move Commit to Another Branch](https://linuxhandbook.com/git-move-commit-branch/) - [Git Show Files in a Commit](https://linuxhandbook.com/git-show-files-commit/) - [Check Git Commit History](https://linuxhandbook.com/git-commit-history/) - [Amend a Comment in Git](https://linuxhandbook.com/git-amend-commit/) Using Git Using Git [Introduction to Flatpak](https://linuxhandbook.com/flatpak/) [Learn Firewalld: Manage Linux Firewall with firewall-cmd](https://linuxhandbook.com/firewalld/) [Getting Started With Nano Editor](https://linuxhandbook.com/learn-nano/) [Start Learning Vim](https://linuxhandbook.com/learn-vim/) [Learn Zsh](https://linuxhandbook.com/learn-zsh/) [Using Git](https://linuxhandbook.com/using-git/) [Rethinking DevOps](https://linuxhandbook.com/rethinking-devops/) [Exploring Ansible Modules](https://linuxhandbook.com/ansible-modules/) [Pentora Box: Pen-Test Practice Labs](https://linuxhandbook.com/pentora-box/) # Git Move Commit to Another Branch Sometimes you commit to an incorrect branch and now you want to move the commit to the correct branch. Here's how to handle the situation. ![Git Move Commit to Another Branch](https://linuxhandbook.com/content/images/size/w2400/2024/06/git-move-commit-to-another-branch.png) [![Warp Terminal](https://linuxhandbook.com/assets/images/warp.webp)](https://www.warp.dev/?utm_source=linux_handbook&utm_medium=display&utm_campaign=linux_launch) Sh(g)it happens. I mean it is usual to clone the main branch, create or switch to a dev branch and then commit the changes to this dev branch which is merged to the main later. Imagine you follow the same only you forget to switch to the dev branch and you made the commit to the main branch. But before pushing, you want to move this commit to the dev branch instead. You should also remove the commit from the main vranch. Let me help you by showing the steps for: - Moving the commit to the correct branch - Reverting the commit from the incorrect branch ## Moving commit to another branch First, let's address the issue that I encountered: While working with three branches, I was supposed to make one commit to the `header` branch and another to the `footer` branch. The first commit to the `header` branch was correct but unfortunately, I made the second commit to the `header` branch instead of the `footer` branch: ![Commit made to wrong branch](https://linuxhandbook.com/content/images/2024/03/Commit-made-to-wrong-branch.png) When I checked the git log, it was pretty clear to me that I made a commit to the wrong branch: ![Checking git log](https://linuxhandbook.com/content/images/2024/03/Checking-git-log.png) Now, let's take a look at the steps to move the commit to another branch. ### Step 1: Find the hash of the commit To find the hash of the commit you want to move, you can use the `git log` in the beach where you made a wrong commit. I made a wrong commit in the `head` branch so I'll be using `git log` there: ``` git log ``` ![Find the hash of the commit](https://linuxhandbook.com/content/images/2024/03/Find-the-hash-of-the-commit.png) Once you find the hash, copy the hash. ### Step 2: Switch to the target branch Next, switch the branch in which you want to move the commit. For that purpose, you can use the `git checkout` command: ``` git checkout <branch-name> ``` In my case, I want to move to commit to the `footer` beach, so I'll be using the following: ``` git checkout footer ``` ![Switch branch in git](https://linuxhandbook.com/content/images/2024/03/Switch-branch-in-git.png) ### Step 3: Move the commit to the target branch Once you switch to the target branch, use the `git cherry-pick` command along with the hash you copied from the first step: ``` git cherry-pick <hash> ``` ![Move git commit to another branch using cherry-pick](https://linuxhandbook.com/content/images/2024/03/Move-git-commit-to-another-branch-using-cherry-pick.png) To verify if the commit was moved or not, you can check the git log: ``` git log ``` ![Verify if the commit was moved successfully to correct branch](https://linuxhandbook.com/content/images/2024/03/Verify-if-the-commit-was-moved-successfully-to-correct-branch.png) There you go\! ## Revert the incorrect commit When you use the `cherry-pick` command, it does not move the commit but copies the commit to the current branch. So you are still left with the incorrect commit on the first branch. The solution is to [revert the incorrect commit](https://linuxhandbook.com/git-undo-commit/). For that, first switch to the branch in which you made the incorrect commit: ``` git checkout <branch-name> ``` In my case, the beach name was `header` so I will be using the following: ``` git checkout header ``` Now, if you check the git log, you will still find the incorrect commit which you recently moved using the `git cherry-pick` command: ![Incorrect commit is still in the first branch](https://linuxhandbook.com/content/images/2024/03/Incorrect-commit-is-still-in-the-first-branch.png) To revert this commit, you append the hash of the target commit to the `git revert` command as shown here: ``` git revert <hash> ``` It will open the text editor telling you it is reverting the commit. It creates another commit without those changes resulting removal of the specified commit. Close the text editor and that's it: ![](https://linuxhandbook.com/content/images/2024/03/revert-git-commit.png) Once you close the text editor, you will see an output telling you that the commit has been deleted: ![Revert incorrect git commit](https://linuxhandbook.com/content/images/2024/03/Revert-incorrect-git-commit.png) There you have it\! ## Wrapping Up In this tutorial, I went through how you can move your commit to a different branch and also explained how you can remove the incorrect commit. I hope you will find this guide helpful. If you have any queries, feel free to leave us a comment. Updated on Jun 28, 2024 Comments Share Copy link [Share to X](https://x.com/intent/tweet?url=https%3A%2F%2Flinuxhandbook.com%2Fgit-move-commit-branch%2F&text=Git%20Move%20Commit%20to%20Another%20Branch) [Share to Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Flinuxhandbook.com%2Fgit-move-commit-branch%2F) [Share to Linkedin](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Flinuxhandbook.com%2Fgit-move-commit-branch%2F) Copied [Previous](https://linuxhandbook.com/git-move-commit-branch/) [Next](https://linuxhandbook.com/git-move-commit-branch/) ## About the author [![Sagar Sharma](https://linuxhandbook.com/content/images/size/w100/2022/11/Sagar-Sharma-new.jpg) Sagar Sharma](https://linuxhandbook.com/author/sagar/) A software engineer who loves to tinker with hardware till it gets crashed. While reviving my crashed system, you can find me reading literature, manga, or watering my plants. [View profile](https://linuxhandbook.com/author/sagar/) ## On this page [![Linux Handbook](https://linuxhandbook.com/content/images/2021/08/linux-handbook-cover.png)](https://linuxhandbook.com/) An independent, reader-supported publication focusing on Linux Command Line, Server, Self-hosting, DevOps and Cloud Learning ## Subscribe to our newsletter Get the latest posts and updates delivered to your inbox. No spam. Unsubscribe anytime. Enter your email Subscribe - [Contact](https://linuxhandbook.com/contact/) - [Pro Resources](https://linuxhandbook.com/member-resources/) - [Membership FAQ](https://linuxhandbook.com/membership-faq/) - [Cheat Sheets](https://linuxhandbook.com/cheatsheets/) - [Privacy Policy](https://linuxhandbook.com/privacy-policy/) - [Write for Us](https://linuxhandbook.com/write-for-us/) - [Terms of Use](https://linuxhandbook.com/terms/) [Linux Handbook](https://linuxhandbook.com/) ยฉ 2026 ยท Hosted on [DigitalOcean](https://m.do.co/c/d58840562553) (get \$200 in FREE credits). Published with [Ghost](https://ghost.org/?via=abhishek70) and [Spiritix](https://spiritix.co/?aff=GNoD0)
Readable Markdown
[![Warp Terminal](https://linuxhandbook.com/assets/images/warp.webp)](https://www.warp.dev/?utm_source=linux_handbook&utm_medium=display&utm_campaign=linux_launch) Sh(g)it happens. I mean it is usual to clone the main branch, create or switch to a dev branch and then commit the changes to this dev branch which is merged to the main later. Imagine you follow the same only you forget to switch to the dev branch and you made the commit to the main branch. But before pushing, you want to move this commit to the dev branch instead. You should also remove the commit from the main vranch. Let me help you by showing the steps for: - Moving the commit to the correct branch - Reverting the commit from the incorrect branch ## Moving commit to another branch First, let's address the issue that I encountered: While working with three branches, I was supposed to make one commit to the `header` branch and another to the `footer` branch. The first commit to the `header` branch was correct but unfortunately, I made the second commit to the `header` branch instead of the `footer` branch: ![Commit made to wrong branch](https://linuxhandbook.com/content/images/2024/03/Commit-made-to-wrong-branch.png) When I checked the git log, it was pretty clear to me that I made a commit to the wrong branch: ![Checking git log](https://linuxhandbook.com/content/images/2024/03/Checking-git-log.png) Now, let's take a look at the steps to move the commit to another branch. ### Step 1: Find the hash of the commit To find the hash of the commit you want to move, you can use the `git log` in the beach where you made a wrong commit. I made a wrong commit in the `head` branch so I'll be using `git log` there: ``` git log ``` ![Find the hash of the commit](https://linuxhandbook.com/content/images/2024/03/Find-the-hash-of-the-commit.png) Once you find the hash, copy the hash. ### Step 2: Switch to the target branch Next, switch the branch in which you want to move the commit. For that purpose, you can use the `git checkout` command: ``` git checkout <branch-name> ``` In my case, I want to move to commit to the `footer` beach, so I'll be using the following: ``` git checkout footer ``` ![Switch branch in git](https://linuxhandbook.com/content/images/2024/03/Switch-branch-in-git.png) ### Step 3: Move the commit to the target branch Once you switch to the target branch, use the `git cherry-pick` command along with the hash you copied from the first step: ``` git cherry-pick <hash> ``` ![Move git commit to another branch using cherry-pick](https://linuxhandbook.com/content/images/2024/03/Move-git-commit-to-another-branch-using-cherry-pick.png) To verify if the commit was moved or not, you can check the git log: ``` git log ``` ![Verify if the commit was moved successfully to correct branch](https://linuxhandbook.com/content/images/2024/03/Verify-if-the-commit-was-moved-successfully-to-correct-branch.png) There you go\! ## Revert the incorrect commit When you use the `cherry-pick` command, it does not move the commit but copies the commit to the current branch. So you are still left with the incorrect commit on the first branch. The solution is to [revert the incorrect commit](https://linuxhandbook.com/git-undo-commit/). For that, first switch to the branch in which you made the incorrect commit: ``` git checkout <branch-name> ``` In my case, the beach name was `header` so I will be using the following: ``` git checkout header ``` Now, if you check the git log, you will still find the incorrect commit which you recently moved using the `git cherry-pick` command: ![Incorrect commit is still in the first branch](https://linuxhandbook.com/content/images/2024/03/Incorrect-commit-is-still-in-the-first-branch.png) To revert this commit, you append the hash of the target commit to the `git revert` command as shown here: ``` git revert <hash> ``` It will open the text editor telling you it is reverting the commit. It creates another commit without those changes resulting removal of the specified commit. Close the text editor and that's it: ![](https://linuxhandbook.com/content/images/2024/03/revert-git-commit.png) Once you close the text editor, you will see an output telling you that the commit has been deleted: ![Revert incorrect git commit](https://linuxhandbook.com/content/images/2024/03/Revert-incorrect-git-commit.png) There you have it\! ## Wrapping Up In this tutorial, I went through how you can move your commit to a different branch and also explained how you can remove the incorrect commit. I hope you will find this guide helpful. If you have any queries, feel free to leave us a comment.
Shard46 (laksa)
Root Hash392173076776213246
Unparsed URLcom,linuxhandbook!/git-move-commit-branch/ s443