ℹ️ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 0.3 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.endpointdev.com/blog/2012/06/moving-commit-to-another-branch-in-git/ |
| Last Crawled | 2026-04-15 21:03:49 (8 days ago) |
| First Indexed | 2021-10-22 22:18:23 (4 years ago) |
| HTTP Status Code | 200 |
| Content | |
| Meta Title | Moving a Commit to Another Branch in Git | End Point Dev |
| Meta Description | null |
| Meta Canonical | null |
| Boilerpipe Text | Perhaps you’ve made the same mistake I have. You’re right in the middle of developing a feature when a request comes up to fix a different completely unrelated problem. So, you jump right in and fix the issue and then you realize you forgot to start a new git feature branch. Suddenly you realize that you need to merge just the fix you made, but don’t want to merge the commits from the previous feature your working on.
Git rocks at manipulating branches and I knew this, but I wasn’t sure how to just move one commit to the master branch. After some digging and a little trial and error, I finally figured it out. This may not be the simplest approach, but it worked for me and wanted to share.
The branches I’ll be working with are master and feature. In the current scenario, the feature branch is 4 commits ahead of the master and the branch that I want to bring over is just the most recent.
First things first, I need to ensure my master branch is up to date.
git checkout master
git pull origin master
Then I’ll checkout my feature branch and make sure it’s completely up to date with the master branch.
git checkout feature
git rebase origin/master
Next, I’ll create a temporary feature branch that I’ll use later on to bring over the commit that I want.
git checkout -b feature_tmp
I’ll do the same for master so that I can perform my merging and rebasing in isolation from the master branch.
git checkout master
git checkout -b master_tmp
Now I’m going to merge the two tmp branches so that I have a history that contains all of my commits. This will give me the history that I want, but will include the 3 commits I don’t want.
git merge feature_tmp
Here’s where the magic happens. I’m going to rebase this branch using interactive mode. I want to rebase everything back to the last commit on the master branch. For simplicity in the commands here, we’ll just use SHA-MASTER in place of the actual SHA1 hash.
git rebase -i SHA-MASTER
This loads the commits into my editor and from here I just delete the 3 commits that I didn’t want on my master branch. This will give me the history I want with the 4th commit coming right after the last commit on the master branch. After deleting the commits, I just save and quit my editor.
Next, I merge my tmp branch into the master branch.
git checkout master
git merge master_tmp
git log
Now in the log, I can see the history is in the correct order, just how I wanted it. To finish things up, I’ll just push my changes and then rebase my feature branch which will reorder my commits to match the master branch and place my feature commits as the last three commits in the log.
git push origin master
git checkout feature
git rebase origin/master
git log
The last thing to do is delete my tmp branches.
git branch -D tmp_master
git branch -D tmp_feature
git |
| Markdown | [Skip to content](https://www.endpointdev.com/blog/2012/06/moving-commit-to-another-branch-in-git/#main-content)
Ă—
[Home](https://www.endpointdev.com/)
***
[Custom Ecommerce](https://www.endpointdev.com/custom-ecommerce/)
[Application Development](https://www.endpointdev.com/application-development/)
[Database Consulting](https://www.endpointdev.com/database-consulting/)
[Cloud Hosting](https://www.endpointdev.com/cloud-hosting/)
[Systems Integration](https://www.endpointdev.com/systems-integration/)
[Legacy Business Systems](https://www.endpointdev.com/legacy-business-systems/)
[Security & Compliance](https://www.endpointdev.com/security-and-compliance/)
[GIS](https://www.endpointdev.com/gis/)
***
[Expertise](https://www.endpointdev.com/expertise/)
***
[About Us](https://www.endpointdev.com/about/)
[Our Team](https://www.endpointdev.com/team/)
[Clients](https://www.endpointdev.com/clients/)
[Blog](https://www.endpointdev.com/blog/)
[Careers](https://www.endpointdev.com/careers/)
***
[VisionPort](https://www.visionport.com/)
***
[Contact](https://www.endpointdev.com/contact/)
[End Point Dev](https://www.endpointdev.com/)
[Services](https://www.endpointdev.com/)
[Expertise](https://www.endpointdev.com/expertise/)
[About](https://www.endpointdev.com/about/)
[VisionPort](https://www.visionport.com/)
[Contact](https://www.endpointdev.com/contact/)
[Custom Ecommerce](https://www.endpointdev.com/custom-ecommerce/)
[Application Development](https://www.endpointdev.com/application-development/)
[Database Consulting](https://www.endpointdev.com/database-consulting/)
[Cloud Hosting](https://www.endpointdev.com/cloud-hosting/)
[Systems Integration](https://www.endpointdev.com/systems-integration/)
[Legacy Business Systems](https://www.endpointdev.com/legacy-business-systems/)
[Security & Compliance](https://www.endpointdev.com/security-and-compliance/)
[GIS](https://www.endpointdev.com/gis/)
### DevOps / Cloud
- [AI Portal](https://www.endpointdev.com/expertise/ai-portal/)
- [AI Tools](https://www.endpointdev.com/expertise/ai-tools/)
- [Containers & Virtualization](https://www.endpointdev.com/expertise/containers-virtualization/)
- [Deployment Automation](https://www.endpointdev.com/expertise/chef-ansible-puppet/)
- [Hosting, Monitoring, and 24x7 Support](https://www.endpointdev.com/expertise/hosting-monitoring/)
- [Linux Systems](https://www.endpointdev.com/expertise/linux-systems/)
- [Remote Monitoring & Management](https://www.endpointdev.com/expertise/rmm/)
- [ROS, Robotics, Embedded Systems](https://www.endpointdev.com/expertise/robotics-embedded-systems/)
- [Security, Encryption, Vulnerability Mitigation](https://www.endpointdev.com/expertise/security-encryption/)
- [Version Control & DevCamps](https://www.endpointdev.com/expertise/version-control-devcamps/)
- [Windows Systems](https://www.endpointdev.com/expertise/windows-systems/)
### Databases
- [Benchmarking](https://www.endpointdev.com/expertise/benchmarking/)
- [Database Migrations](https://www.endpointdev.com/expertise/migrations/)
- [Microsoft SQL Server](https://www.endpointdev.com/expertise/sqlserver/)
- [MySQL](https://www.endpointdev.com/expertise/mysql/)
- [NoSQL](https://www.endpointdev.com/expertise/nosql/)
- [On-site Training and Support](https://www.endpointdev.com/expertise/training-support/)
- [PostgreSQL](https://www.endpointdev.com/expertise/postgresql/)
- [Replication & Bucardo](https://www.endpointdev.com/expertise/replication/)
- [Support and Maintenance Packages](https://www.endpointdev.com/expertise/support-maintenance/)
### Frameworks
- [Android & iOS Development](https://www.endpointdev.com/expertise/mobile/)
- [ASP, .NET, C\#](https://www.endpointdev.com/expertise/dot-net/)
- [CMS (WordPress, Wix, Craft, custom)](https://www.endpointdev.com/expertise/cms/)
- [Django & Python](https://www.endpointdev.com/expertise/django-python/)
- [Elasticsearch, Solr](https://www.endpointdev.com/expertise/search/)
- [Geographic Information Systems](https://www.endpointdev.com/expertise/gis/)
- [Java](https://www.endpointdev.com/expertise/java/)
- [JavaScript](https://www.endpointdev.com/expertise/javascript/)
- [PHP](https://www.endpointdev.com/expertise/php/)
- [Ruby on Rails](https://www.endpointdev.com/expertise/ruby-on-rails/)
### Ecommerce
- [End Point Ecommerce](https://www.endpointdev.com/expertise/end-point-ecommerce/)
- [APIs and Integrations](https://www.endpointdev.com/expertise/apis/)
- [Magento](https://www.endpointdev.com/expertise/magento/)
- [Payment Processing](https://www.endpointdev.com/expertise/payment/)
- [Perl & Interchange](https://www.endpointdev.com/expertise/perl-interchange/)
- [Responsive Design](https://www.endpointdev.com/expertise/responsive-design/)
- [SEO, Google Ads, Analytics](https://www.endpointdev.com/expertise/analytics/)
- [Spree and Solidus](https://www.endpointdev.com/expertise/spree-solidus/)
[About Us We design and build custom software solutions.](https://www.endpointdev.com/about/)
[Our Team We’re software developers, design thinkers, and security experts.](https://www.endpointdev.com/team/)
[Clients Since 1995 we’ve built our reputation by bringing expertise and care to your projects.](https://www.endpointdev.com/clients/)
[Blog Ongoing observations by End Point Dev people](https://www.endpointdev.com/blog/)
[Careers We currently have no open positions, but check back soon\!](https://www.endpointdev.com/careers/)
[Our Blog](https://www.endpointdev.com/blog/)
[](https://www.endpointdev.com/blog/feed.xml)
[Search]() [LLM expanded search]()
***
[Hide search results](https://www.endpointdev.com/blog/2012/06/moving-commit-to-another-branch-in-git/)
## Moving a Commit to Another Branch in Git
[](https://www.endpointdev.com/blog/authors/mike-farmer/)
By [Mike Farmer](https://www.endpointdev.com/blog/authors/mike-farmer/)
June 21, 2012
Perhaps you’ve made the same mistake I have. You’re right in the middle of developing a feature when a request comes up to fix a different completely unrelated problem. So, you jump right in and fix the issue and then you realize you forgot to start a new git feature branch. Suddenly you realize that you need to merge just the fix you made, but don’t want to merge the commits from the previous feature your working on.
Git rocks at manipulating branches and I knew this, but I wasn’t sure how to just move one commit to the master branch. After some digging and a little trial and error, I finally figured it out. This may not be the simplest approach, but it worked for me and wanted to share.
The branches I’ll be working with are master and feature. In the current scenario, the feature branch is 4 commits ahead of the master and the branch that I want to bring over is just the most recent.
First things first, I need to ensure my master branch is up to date.
```
git checkout master
git pull origin master
```
Then I’ll checkout my feature branch and make sure it’s completely up to date with the master branch.
```
git checkout feature
git rebase origin/master
```
Next, I’ll create a temporary feature branch that I’ll use later on to bring over the commit that I want.
```
git checkout -b feature_tmp
```
I’ll do the same for master so that I can perform my merging and rebasing in isolation from the master branch.
```
git checkout master
git checkout -b master_tmp
```
Now I’m going to merge the two tmp branches so that I have a history that contains all of my commits. This will give me the history that I want, but will include the 3 commits I don’t want.
```
git merge feature_tmp
```
Here’s where the magic happens. I’m going to rebase this branch using interactive mode. I want to rebase everything back to the last commit on the master branch. For simplicity in the commands here, we’ll just use SHA-MASTER in place of the actual SHA1 hash.
```
git rebase -i SHA-MASTER
```
This loads the commits into my editor and from here I just delete the 3 commits that I didn’t want on my master branch. This will give me the history I want with the 4th commit coming right after the last commit on the master branch. After deleting the commits, I just save and quit my editor.
Next, I merge my tmp branch into the master branch.
```
git checkout master
git merge master_tmp
git log
```
Now in the log, I can see the history is in the correct order, just how I wanted it. To finish things up, I’ll just push my changes and then rebase my feature branch which will reorder my commits to match the master branch and place my feature commits as the last three commits in the log.
```
git push origin master
git checkout feature
git rebase origin/master
git log
```
The last thing to do is delete my tmp branches.
```
git branch -D tmp_master
git branch -D tmp_feature
```
[git](https://www.endpointdev.com/blog/tags/git/)
***
## Comments
Visit the [GitHub issue](https://github.com/EndPointCorp/end-point-blog/issues/655) to view and write comments.
### Popular Tags
- [postgres 305](https://www.endpointdev.com/blog/tags/postgres/)
- [rails 267](https://www.endpointdev.com/blog/tags/rails/)
- [conference 194](https://www.endpointdev.com/blog/tags/conference/)
- [database 179](https://www.endpointdev.com/blog/tags/database/)
- [ruby 166](https://www.endpointdev.com/blog/tags/ruby/)
- [ecommerce 162](https://www.endpointdev.com/blog/tags/ecommerce/)
- [javascript 148](https://www.endpointdev.com/blog/tags/javascript/)
- [visionport 144](https://www.endpointdev.com/blog/tags/visionport/)
- [perl 117](https://www.endpointdev.com/blog/tags/perl/)
- [open-source 115](https://www.endpointdev.com/blog/tags/open-source/)
- [sysadmin 106](https://www.endpointdev.com/blog/tags/sysadmin/)
- [tips 106](https://www.endpointdev.com/blog/tags/tips/)
- [All Tags](https://www.endpointdev.com/blog/tags/)
***
### Archive
- [Posts by date](https://www.endpointdev.com/blog/archive/)
- [Posts by author](https://www.endpointdev.com/blog/authors/)
- [Services](https://www.endpointdev.com/)
- [Custom Ecommerce](https://www.endpointdev.com/custom-ecommerce/)
- [Application Development](https://www.endpointdev.com/application-development/)
- [Database Consulting](https://www.endpointdev.com/database-consulting/)
- [Cloud Hosting](https://www.endpointdev.com/cloud-hosting/)
- [Systems Integration](https://www.endpointdev.com/systems-integration/)
- [Legacy Business Systems](https://www.endpointdev.com/legacy-business-systems/)
- [Security & Compliance](https://www.endpointdev.com/security-and-compliance/)
- [GIS](https://www.endpointdev.com/gis/)
- [Expertise](https://www.endpointdev.com/expertise/)
- [DevOps / Cloud](https://www.endpointdev.com/expertise/#devops-cloud)
- [Databases](https://www.endpointdev.com/expertise/#databases)
- [Frameworks](https://www.endpointdev.com/expertise/#frameworks)
- [Ecommerce](https://www.endpointdev.com/expertise/#ecommerce)
- [About](https://www.endpointdev.com/about/)
- [Our Team](https://www.endpointdev.com/team/)
- [Clients](https://www.endpointdev.com/clients/)
- [Blog](https://www.endpointdev.com/blog/)
- [Careers](https://www.endpointdev.com/careers/)
- [VisionPort](https://www.visionport.com/)
- [Contact](https://www.endpointdev.com/contact/)
[](https://www.linkedin.com/company/end-point-corporation) [](https://x.com/endpointdev) [](https://instagram.com/endpointcorporation)
© 2026 End Point Corporation |
| Readable Markdown | Perhaps you’ve made the same mistake I have. You’re right in the middle of developing a feature when a request comes up to fix a different completely unrelated problem. So, you jump right in and fix the issue and then you realize you forgot to start a new git feature branch. Suddenly you realize that you need to merge just the fix you made, but don’t want to merge the commits from the previous feature your working on.
Git rocks at manipulating branches and I knew this, but I wasn’t sure how to just move one commit to the master branch. After some digging and a little trial and error, I finally figured it out. This may not be the simplest approach, but it worked for me and wanted to share.
The branches I’ll be working with are master and feature. In the current scenario, the feature branch is 4 commits ahead of the master and the branch that I want to bring over is just the most recent.
First things first, I need to ensure my master branch is up to date.
```
git checkout master
git pull origin master
```
Then I’ll checkout my feature branch and make sure it’s completely up to date with the master branch.
```
git checkout feature
git rebase origin/master
```
Next, I’ll create a temporary feature branch that I’ll use later on to bring over the commit that I want.
```
git checkout -b feature_tmp
```
I’ll do the same for master so that I can perform my merging and rebasing in isolation from the master branch.
```
git checkout master
git checkout -b master_tmp
```
Now I’m going to merge the two tmp branches so that I have a history that contains all of my commits. This will give me the history that I want, but will include the 3 commits I don’t want.
```
git merge feature_tmp
```
Here’s where the magic happens. I’m going to rebase this branch using interactive mode. I want to rebase everything back to the last commit on the master branch. For simplicity in the commands here, we’ll just use SHA-MASTER in place of the actual SHA1 hash.
```
git rebase -i SHA-MASTER
```
This loads the commits into my editor and from here I just delete the 3 commits that I didn’t want on my master branch. This will give me the history I want with the 4th commit coming right after the last commit on the master branch. After deleting the commits, I just save and quit my editor.
Next, I merge my tmp branch into the master branch.
```
git checkout master
git merge master_tmp
git log
```
Now in the log, I can see the history is in the correct order, just how I wanted it. To finish things up, I’ll just push my changes and then rebase my feature branch which will reorder my commits to match the master branch and place my feature commits as the last three commits in the log.
```
git push origin master
git checkout feature
git rebase origin/master
git log
```
The last thing to do is delete my tmp branches.
```
git branch -D tmp_master
git branch -D tmp_feature
```
[git](https://www.endpointdev.com/blog/tags/git/)
*** |
| ML Classification | |
| ML Categories | null |
| ML Page Types | null |
| ML Intent Types | null |
| Content Metadata | |
| Language | en |
| Author | null |
| Publish Time | not set |
| Original Publish Time | 2012-06-01 00:00:00 (13 years ago) |
| Republished | No |
| Word Count (Total) | 859 |
| Word Count (Content) | 520 |
| Links | |
| External Links | 6 |
| Internal Links | 72 |
| Technical SEO | |
| Meta Nofollow | No |
| Meta Noarchive | No |
| JS Rendered | No |
| Redirect Target | null |
| Performance | |
| Download Time (ms) | 82 |
| TTFB (ms) | 81 |
| Download Size (bytes) | 6,921 |
| Shard | 67 (laksa) |
| Root Hash | 15777514137560783467 |
| Unparsed URL | com,endpointdev!www,/blog/2012/06/moving-commit-to-another-branch-in-git/ s443 |