ℹ️ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | FAIL | download_stamp > now() - 6 MONTH | 6.7 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://www.howtogeek.com/devops/how-to-move-changes-to-another-branch-in-git/ |
| Last Crawled | 2025-09-24 14:26:50 (6 months ago) |
| First Indexed | 2022-04-29 06:45:28 (3 years ago) |
| HTTP Status Code | 200 |
| Meta Title | How to Move Changes to Another Branch in Git |
| Meta Description | While Git keeps track of your day to day changes, it also features systems like branches that help you organize. |
| Meta Canonical | null |
| Boilerpipe Text | Jump Links Moving Changes (If You Haven't Committed Yet) Moving Commits (If You Already Committed) Summary
Git helps organize changes with branches, but wrong commits can cause problems.
To move changes, switch branches using the "git checkout <branch>" command.
To correct committed mistakes, soft reset before switching so your changes aren't commited yet.
While Git keeps track of your daily changes, it also features systems like branches that help you organize. If you're not careful, though, you can end up with problems like commits and changes made to the wrong branch that can be difficult to solve without the right commands.
Moving Changes (If You Haven't Committed Yet)
Git watches over your whole folder, but changes you make to files are not tied to a specific Git branch until you commit them. You can move branches, and bring those changes along with you. The simplest option is to simply switch branches, but this will only work if the two branches you're targeting have a matching history : git checkout feature You can get around this in a few ways. The first is by making a new branch, and then merging the diverging histories: git checkout -b tempfeature git checkout feature git merge tempfeature You can also use git stash to store changes for later, and reapply them on a new branch: git stash git switch feature git stash apply
Moving Commits (If You Already Committed)
If you already committed, don't worry; you can always soft reset, so commits are not final until pushed to remote source control. If you did that already, you can still fix the problem, but the record of your mistake will live on in your Git history , so it's best to do it locally before your coworkers see it. To undo commits , you can simply soft reset, usually just undoing the last commit made, but you can also pass in a reference to the commit ID: git reset HEAD~1 This will leave you at the "haven't committed yet" state, after which you can use the methods above to fix the problem. Alternatively, you can use git cherry-pick . This command copies commits from one branch to another, and is a nice way of picking out commits and moving them to new branches in a clean manner. Run git log to find the ID of the commit you want to revert: git log Then checkout the feature branch, assuming your changes have been committed, and run cherry-pick : git switch feature git cherry-pick After that, there will still be a duplicate commit on the main branch. You can reset this and discard the changes if the feature branch is in proper order, or keep it and let Git sort it out once you merge. If you want to learn more about using Git, read about how you can always know what branch you're in , or see if you know all the basic Git commands . |
| Markdown | Menu
[](https://www.howtogeek.com/)
Sign in now
Close
- - [Desktop](https://www.howtogeek.com/category/desktop/)
Submenu
- [Windows](https://www.howtogeek.com/category/windows/)
- [Mac](https://www.howtogeek.com/category/mac/)
- [Linux](https://www.howtogeek.com/category/linux/)
- [Chromebook](https://www.howtogeek.com/category/chromebook-chrome-os/)
- [Microsoft](https://www.howtogeek.com/category/microsoft/)
- [Programming](https://www.howtogeek.com/category/programming/)
- [Mobile](https://www.howtogeek.com/category/mobile/)
Submenu
- [Android](https://www.howtogeek.com/category/android/)
- [iPhone](https://www.howtogeek.com/category/ios/)
- [Cellular Carriers](https://www.howtogeek.com/category/cellular-carriers/)
- [Gaming](https://www.howtogeek.com/category/video-games/)
- [Streaming](https://www.howtogeek.com/category/streaming/)
Submenu
- [Audio/Video](https://www.howtogeek.com/category/audio/)
- [Web](https://www.howtogeek.com/category/web/)
Submenu
- [Cyber Security](https://www.howtogeek.com/category/cybersecurity/)
- [Google](https://www.howtogeek.com/tag/google/)
- [Automotive](https://www.howtogeek.com/category/automotive/)
- [Hobbies](https://www.howtogeek.com/category/hobbies/)
- Science Submenu
- [Space](https://www.howtogeek.com/category/space/)
- [Cutting Edge](https://www.howtogeek.com/category/cutting-edge/)
- [News](https://www.howtogeek.com/news/)
- [Reviews](https://www.howtogeek.com/category/product-reviews/)
- [Buying Guides](https://www.howtogeek.com/buying-guides/)
- [Deals](https://www.howtogeek.com/tag/deals/)
- [Sign in](https://www.howtogeek.com/devops/how-to-move-changes-to-another-branch-in-git/)
- [Newsletter](https://www.howtogeek.com/page/newsletter/)
Menu
[](https://www.howtogeek.com/)
Follow
Followed
Like
[Threads](https://www.howtogeek.com/devops/how-to-move-changes-to-another-branch-in-git/#threads "Threads")
More Action
Sign in now
[iPhone](https://www.howtogeek.com/category/ios/)
[Windows](https://www.howtogeek.com/category/windows/)
[Linux](https://www.howtogeek.com/category/linux/)
[Open Source Tools](https://www.howtogeek.com/tag/open-source/)
[Android](https://www.howtogeek.com/category/android/)
[Streaming](https://www.howtogeek.com/category/streaming/)
[Microsoft Excel](https://www.howtogeek.com/tag/microsoft-excel/)
[Deals](https://www.howtogeek.com/tag/deals/)
Close
# How to Move Changes to Another Branch in Git

Credit: Lucas Gouveia / How-To Geek
[](https://www.howtogeek.com/author/anthony-heddings/)
[](https://www.howtogeek.com/author/jordangloor/)
By [Anthony Heddings](https://www.howtogeek.com/author/anthony-heddings/) & [Jordan Gloor](https://www.howtogeek.com/author/jordangloor/)
Updated
Dec 11, 2024
### Related
[](https://www.howtogeek.com/how-i-got-windows-11-running-on-a-decade-old-pc-with-flyoobe/)
##### [How I Got Windows 11 Running on a Decade-Old "Unsupported" PC](https://www.howtogeek.com/how-i-got-windows-11-running-on-a-decade-old-pc-with-flyoobe/ "How I Got Windows 11 Running on a Decade-Old \"Unsupported\" PC")
[](https://www.howtogeek.com/things-nobody-tells-you-about-switching-to-linux-from-windows/)
##### [5 Things Nobody Tells You About Switching to Linux from Windows](https://www.howtogeek.com/things-nobody-tells-you-about-switching-to-linux-from-windows/ "5 Things Nobody Tells You About Switching to Linux from Windows")
[](https://www.howtogeek.com/you-probably-already-have-the-perfect-solution-to-your-drawer-of-tangled-cables/)
##### [You Probably Already Have the Perfect Solution to Your Drawer of Tangled Cables](https://www.howtogeek.com/you-probably-already-have-the-perfect-solution-to-your-drawer-of-tangled-cables/ "You Probably Already Have the Perfect Solution to Your Drawer of Tangled Cables")
[Sign in to your How-To Geek account]()
Jump links
### Jump Links
- [Moving Changes (If You Haven't Committed Yet)](https://www.howtogeek.com/devops/how-to-move-changes-to-another-branch-in-git/#moving-changes-if-you-haven-39-t-committed-yet)
- [Moving Commits (If You Already Committed)](https://www.howtogeek.com/devops/how-to-move-changes-to-another-branch-in-git/#moving-commits-if-you-already-committed)
follow
Follow
followed
Followed
Like
Like
[Thread](https://www.howtogeek.com/devops/how-to-move-changes-to-another-branch-in-git/#threads "Threads")
Log in
Here is a fact-based summary of the story contents:
Try something different:
Show me the facts
Explain it like I’m 5
Give me a lighthearted recap
### Jump Links
- [Moving Changes (If You Haven't Committed Yet)](https://www.howtogeek.com/devops/how-to-move-changes-to-another-branch-in-git/#moving-changes-if-you-haven-39-t-committed-yet)
- [Moving Commits (If You Already Committed)](https://www.howtogeek.com/devops/how-to-move-changes-to-another-branch-in-git/#moving-commits-if-you-already-committed)
### Summary
- Git helps organize changes with branches, but wrong commits can cause problems.
- To move changes, switch branches using the "git checkout \<branch\>" command.
- To correct committed mistakes, soft reset before switching so your changes aren't commited yet.
While Git keeps track of your daily changes, it also features systems like branches that help you organize. If you're not careful, though, you can end up with problems like commits and changes made to the wrong branch that can be difficult to solve without the right commands.
## Moving Changes (If You Haven't Committed Yet)
Git watches over your whole folder, but changes you make to files are not tied to a specific [Git branch](https://www.howtogeek.com/devops/how-do-git-branches-work/) until you commit them. You can move branches, and bring those changes along with you.
The simplest option is to simply switch branches, but this will only work if the two branches you're targeting **have a matching history**:
```
git checkout feature
```
You can get around this in a few ways. The first is by making a new branch, and then merging the diverging histories:
```
```
You can also use `git stash` to store changes for later, and reapply them on a new branch:
```
```
## Moving Commits (If You Already Committed)
If you already committed, don't worry; you can always soft reset, so commits are not final until pushed to remote source control. If you did that already, you can still fix the problem, but the record of your mistake will live on in [your Git history](https://www.howtogeek.com/devops/how-to-view-commit-history-with-git-log/), so it's best to do it locally before your coworkers see it.
To [undo commits](https://www.howtogeek.com/devops/how-to-fix-edit-or-undo-git-commits-changing-git-history/), you can simply soft reset, usually just undoing the last commit made, but you can also pass in a reference to the commit ID:
```
git reset HEAD~1
```
This will leave you at the "haven't committed yet" state, after which you can use the methods above to fix the problem.
Alternatively, you can [use `git cherry-pick`](https://www.howtogeek.com/devops/what-does-git-cherry-pick-do-and-when-should-you-use-it/). This command copies commits from one branch to another, and is a nice way of picking out commits and moving them to new branches in a clean manner.
Run `git log` to find the ID of the commit you want to revert:
```
git log
```
Then [checkout](https://www.howtogeek.com/864263/how-to-checkout-a-remote-git-branch/) the feature branch, assuming your changes have been committed, and run `cherry-pick`:
```
```
After that, there will still be a duplicate commit on the main branch. You can reset this and discard the changes if the feature branch is in proper order, or keep it and let Git sort it out once you merge.
***
If you want to learn more about using Git, read about how you can [always know what branch you're in](https://www.howtogeek.com/always-know-which-git-branch-youre-in-with-this-linux-trick/), or see if you know [all the basic Git commands](https://www.howtogeek.com/basic-git-commands-to-get-you-started/).
- [Programming](https://www.howtogeek.com/category/programming/ "Programming")
- [GitHub](https://www.howtogeek.com/tag/github/ "GitHub")
Follow
Followed
Like
Share
[Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fwww.howtogeek.com%2Fdevops%2Fhow-to-move-changes-to-another-branch-in-git%2F%2F&src=sdkpreparse) [X](https://twitter.com/intent/tweet?text=How%20to%20Move%20Changes%20to%20Another%20Branch%20in%20Git&url=https%3A%2F%2Fwww.howtogeek.com%2Fdevops%2Fhow-to-move-changes-to-another-branch-in-git%2F) [LinkedIn](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fwww.howtogeek.com%2Fdevops%2Fhow-to-move-changes-to-another-branch-in-git%2F&title=How%20to%20Move%20Changes%20to%20Another%20Branch%20in%20Git&source=www.howtogeek.com&summary=While%20Git%20keeps%20track%20of%20your%20day%20to%20day%20changes%2C%20it%20also%20features%20systems%20like%20branches%20that%20help%20you%20organize.) [Reddit](https://www.reddit.com/submit?url=https%3A%2F%2Fwww.howtogeek.com%2Fdevops%2Fhow-to-move-changes-to-another-branch-in-git%2F) [Flipboard](http://share.flipboard.com/bookmarklet/popout?v=2&title=How%20to%20Move%20Changes%20to%20Another%20Branch%20in%20Git&url=https%3A%2F%2Fwww.howtogeek.com%2Fdevops%2Fhow-to-move-changes-to-another-branch-in-git%2F&utm_campaign=tools&utm_medium=article-share&utm_source=www.howtogeek.com) [Copy link]() [Email](<mailto:?Subject=How to Move Changes to Another Branch in Git&Body=Check%20this%20out%21%0Ahttps://www.howtogeek.com/devops/how-to-move-changes-to-another-branch-in-git/>)
Readers like you help support How-To Geek. When you make a purchase using links on our site, we may earn an affiliate commission. [Read More](https://www.valnetinc.com/en/terms-of-use).
Close
Thread
[Sign in to your How-To Geek account]()
We want to hear from you! Share your opinions in the thread below and remember to keep it respectful.
Your comment has not been saved
[Send confirmation email]()
This thread is open for discussion.
Be the first to post your thoughts.
- [Terms](https://www.valnetinc.com/en/terms-of-use)
- [Privacy](https://www.howtogeek.com/page/our-privacy-policy/)
- [Feedback](https://www.howtogeek.com/contact)
Recommended
[](https://www.howtogeek.com/if-you-put-a-case-on-your-iphone-air-im-calling-you-out/)
5 days ago
### [If You Put a Case On Your iPhone Air, I'm Calling You Out](https://www.howtogeek.com/if-you-put-a-case-on-your-iphone-air-im-calling-you-out/ "If You Put a Case On Your iPhone Air, I'm Calling You Out")
[](https://www.howtogeek.com/disabling-startup-apps-improve-boot-time/)
4 days ago
### [I Disabled Windows Startup Apps—Here's How Much Faster My PC Boots](https://www.howtogeek.com/disabling-startup-apps-improve-boot-time/ "I Disabled Windows Startup Apps—Here's How Much Faster My PC Boots")
[](https://www.howtogeek.com/how-an-open-source-app-saves-me-hours-of-work-every-week/)
3 days ago
### [How One Open-Source App Saves Me Hours of Work Every Week](https://www.howtogeek.com/how-an-open-source-app-saves-me-hours-of-work-every-week/ "How One Open-Source App Saves Me Hours of Work Every Week")
[](https://www.howtogeek.com/my-surround-sound-is-15-years-old-and-i-wouldnt-replace-it/)
4 days ago
### [My Surround Sound System Is 15 Years Old and I Still Wouldn't Replace It](https://www.howtogeek.com/my-surround-sound-is-15-years-old-and-i-wouldnt-replace-it/ "My Surround Sound System Is 15 Years Old and I Still Wouldn't Replace It")
- ### Desktop
- ### Mobile
[](https://www.howtogeek.com/alternative-nas-operating-systems-worth-trying/)
##### [5 Alternative NAS Operating Systems Worth Trying](https://www.howtogeek.com/alternative-nas-operating-systems-worth-trying/ "5 Alternative NAS Operating Systems Worth Trying")
11 minutes ago
[](https://www.howtogeek.com/437958/how-to-use-the-chmod-command-on-linux/)
##### [How to Use the chmod Command on Linux](https://www.howtogeek.com/437958/how-to-use-the-chmod-command-on-linux/ "How to Use the chmod Command on Linux")
3 hours ago
[](https://www.howtogeek.com/the-best-earbuds-for-iphone-just-got-even-better/)
##### [The Best Earbuds for iPhone Just Got Even Better](https://www.howtogeek.com/the-best-earbuds-for-iphone-just-got-even-better/ "The Best Earbuds for iPhone Just Got Even Better")
4 hours ago
[See More](https://www.howtogeek.com/category/desktop/)
[](https://www.howtogeek.com/10-great-android-apps-with-bad-widgets/)
##### [10 Great Android Apps With Bad Widgets](https://www.howtogeek.com/10-great-android-apps-with-bad-widgets/ "10 Great Android Apps With Bad Widgets")
26 minutes ago
[](https://www.howtogeek.com/this-is-why-the-iphone-17-pro-is-scratching-so-much/)
##### [This Is Why The iPhone 17 Pro Is Scratching So Much](https://www.howtogeek.com/this-is-why-the-iphone-17-pro-is-scratching-so-much/ "This Is Why The iPhone 17 Pro Is Scratching So Much")
1 hour ago
[](https://www.howtogeek.com/foam-ear-tips-are-a-trendy-upgrade-but-do-they-really-make-your-earbuds-better/)
##### [Foam Ear Tips Are a Trendy Upgrade, but Do They Really Make Your Earbuds Better?](https://www.howtogeek.com/foam-ear-tips-are-a-trendy-upgrade-but-do-they-really-make-your-earbuds-better/ "Foam Ear Tips Are a Trendy Upgrade, but Do They Really Make Your Earbuds Better?")
18 hours ago
[See More](https://www.howtogeek.com/category/mobile/)
Trending Now
[](https://www.howtogeek.com/you-can-now-tell-google-photos-how-to-edit-a-photo-for-you/)
##### [You Can Now Tell Google Photos How to Edit a Photo for You](https://www.howtogeek.com/you-can-now-tell-google-photos-how-to-edit-a-photo-for-you/ "You Can Now Tell Google Photos How to Edit a Photo for You")
[](https://www.howtogeek.com/this-logitech-keyboard-is-powered-by-light/)
##### [This Logitech Keyboard Is Powered By Light](https://www.howtogeek.com/this-logitech-keyboard-is-powered-by-light/ "This Logitech Keyboard Is Powered By Light")
[](https://www.howtogeek.com/this-is-my-favorite-email-client-on-linux-its-not-thunderbird/)
##### [This Is My Favorite Email Client on Linux (And It’s Not Thunderbird)](https://www.howtogeek.com/this-is-my-favorite-email-client-on-linux-its-not-thunderbird/ "This Is My Favorite Email Client on Linux (And It’s Not Thunderbird)")
[](https://www.howtogeek.com/)
- [Join Our Team](https://www.howtogeek.com/work-with-us/)
- [Our Audience](https://www.howtogeek.com/page/advertise/)
- [About Us](https://www.howtogeek.com/page/about/)
- [Press & Events](https://www.howtogeek.com/page/press-events/)
- [Contact Us](https://www.howtogeek.com/contact/)
- Follow Us
[](https://www.valnetinc.com/en/)
- [Advertising](https://www.valnetinc.com/en/advertising)
- [Careers](https://www.valnetinc.com/en/careers)
- [Terms](https://www.valnetinc.com/en/terms-of-use)
- [Privacy](https://www.howtogeek.com/page/our-privacy-policy/)
- [Policies](https://www.howtogeek.com/page/our-editorial-guidelines/)
[How-To Geek](https://www.howtogeek.com/) is part of the [Valnet Publishing Group](https://www.valnetinc.com/en/)
Copyright © 2025 Valnet Inc. |
| Readable Markdown | null |
| Shard | 195 (laksa) |
| Root Hash | 5883057217006082795 |
| Unparsed URL | com,howtogeek!www,/devops/how-to-move-changes-to-another-branch-in-git/ s443 |