🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 93 (from laksa096)

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
6 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://www.eficode.com/blog/what-to-do-when-you-commit-to-the-wrong-git-branch
Last Crawled2026-03-31 16:13:42 (6 days ago)
First Indexed2023-06-26 19:13:21 (2 years ago)
HTTP Status Code200
Meta TitleWhat to do when you commit to the wrong Git branch
Meta DescriptionWhat do you do when you commit to the wrong Git branch? Undo and commit to new branch, or move commits to the other branch? In this post, learn how to do both.
Meta Canonicalnull
Boilerpipe Text
It’s a sunny day, you are having a great time coding, and being the diligent individual you are, you commit regularly. And then it hits you: several commits, all to the wrong branch. What now? Well, this is Git we are talking about, so the good news is that it’s relatively straightforward. Let’s say you committed to master, and you meant to commit to a new branch called “myfeature”. There are two things that need fixing. First of all, you need to revert the master back to where it originally was. And secondly, you need to get your changes on that new branch. Now here are your options: Undo commits on master, checkout new branch myfeature and commit all your changes as one commit. Modify refs manually for the master to point back to where you were and for your new branch ref to. The first solution is nice, simple and easy to apply without a relatively small margin for error. The downside is, however, that you don’t get your original commit messages on the new branch, and all changes are applied as a single commit with a new commit message etc. The second solution is a little more involved. However, it means that all your commits are passed over to the new branch – though, of course, you should check your results before pushing up to your central repo, as it is slightly easier to get wrong. Undo and Commit to New Branch Make sure you are on the branch to which you have been committing. Use git log to check how many commits you want to roll back. Then undo the commits with  git reset HEAD~N where “N” is the number of commits you want to undo. For example, to undo one commit: git reset HEAD~1 Then create a new branch and check it out in one go and add and commit your changes again. git checkout -b newbranch git add -A git commit -m "Committed on new branch" Be careful with the  add -A  though as you may be adding unrelated uncommitted files and directories. Have a look at  git status  before you commit to checking. Move Commits to the Other Branch There is more margin for error with this one. The first step is to take a note of the commit id of the commit you want to make the head of the new branch. git log Copy the commit id to somewhere safe. Then reset your current branch back by one commit (or however many commits you need to go back): git reset --hard HEAD~1 And the final step is to move the commits that follow to the new branch: git checkout -b newbranch git reset --hard < commit_id > And it’s done! Time to push both branches (with  --force  if needed, i.e. if you had previously pushed the changes). However, as always, when using  --force  make sure there are no other commits that follow yours as they would be undone. New to Git? Find out more and get in touch! Published: April 12, 2018 Updated: May 5, 2025 DevOps Atlassian
Markdown
[Skip to main content](https://www.eficode.com/blog/what-to-do-when-you-commit-to-the-wrong-git-branch#main-content) [![Eficode logo](https://www.eficode.com/hubfs/eficode-hs-theme/images/eficode-main-logo-svg.svg)](https://www.eficode.com/?hsLang=en) [Search](https://www.eficode.com/blog/what-to-do-when-you-commit-to-the-wrong-git-branch#cd-search) EN - [FI](https://www.eficode.com/?hsLang=fi) - [DE](https://www.eficode.com/?hsLang=de) - [SV](https://www.eficode.com/?hsLang=sv) Get in touch - [Services](https://www.eficode.com/services/ai-in-product-and-software-development) - Services - [Your path to AI](https://www.eficode.com/services/ai-in-product-and-software-development) - Strategy - [Product management](https://www.eficode.com/services/product-management) - [Governance, risk and compliance](https://www.eficode.com/services/modern-governance-risk-and-compliance) - Transformation - [AI-led software development](https://www.eficode.com/services/ai-success-roadmap-for-software-development) - [DevOps services](https://www.eficode.com/services/devops-transformation) - [Platform engineering](https://www.eficode.com/services/platform-engineering) - [Service management](https://www.eficode.com/services/service-management) - Capabilities - [Continuous services](https://www.eficode.com/continuous-services) - [UX and accessibility](https://www.eficode.com/services/design-and-build-digital-services) - [Contractor hub](https://www.eficode.com/contractor-hub/) - [Training](https://www.eficode.com/services/training) - [Technologies]() - Technologies - [See all solutions]() - [Atlassian](https://www.eficode.com/solutions/atlassian) - Jira, Confluence, Bitbucket... - [GitLab](https://www.eficode.com/solutions/gitlab/) - Services, migration, training... - [GitHub](https://www.eficode.com/solutions/github-enterprise) - Git, Copilot, GitHub Enterprise... - [Eficode ROOT](https://www.eficode.com/services/root-devops-platform) - Developer Platform as a Service - [AWS](https://www.eficode.com/solutions/aws) - AWS Well-Architected Framework and services - [Azure](https://www.eficode.com/solutions/azure) - Consulting and managed services - [Azure DevOps](https://www.eficode.com/solutions/azure-devops) - Migration, consolidation and governance - [![ai and devops illustration](https://www.eficode.com/hubfs/Eficode%202020%20site%20images/Illustrations/ai_and_devops_illustration_nav.svg)**Modernize with AI** Take your software development to the next level and save time, money— and more. Learn how.](https://www.eficode.com/transforming-software-development-with-ai-and-devops) - [Industries](https://www.eficode.com/cases) - Industries - [Meet our clients](https://www.eficode.com/cases) - [Finance](https://www.eficode.com/industries/devops-finance-sector) - DevOps for the highly regulated - [Manufacturing](https://www.eficode.com/industries/devops-manufacturing-sector) - DevOps in the embedded world - [Telecommunication](https://www.eficode.com/industries/telecoms-5g-devops) - 5G and DevOps - [Public sector](https://www.eficode.com/industries/government-and-public-sector) - Atlassian solutions for the public sector - [Defense and aerospace](https://www.eficode.com/industries/agile-and-devops-in-defense) - Agile and DevOps for the defense sector - [![supercell-case-hero-200](https://www.eficode.com/hs-fs/hubfs/Eficode%202020%20site%20images/Blog%20images/supercell-case-hero-200.png?width=200&name=supercell-case-hero-200.png)**AI-powered solution** Enhancing IT support efficiency at Supercell with AI-driven automation](https://www.eficode.com/cases/enhancing-efficiency-in-it-support-at-supercell) - [Client stories](https://www.eficode.com/cases) - Client stories - [See all client stories](https://www.eficode.com/cases) - Featured cases - [![Daimler Truck](https://cdn.bfldr.com/AH757IBR/at/vshnchfhrpw9kqg48bqb4vh/daimler-trucks-logo-nav.svg)Daimler Truck](https://www.eficode.com/cases/daimler-trucks-devops-toolchain) - Reducing app landscape by 40% - [![The Very Group](https://cdn.bfldr.com/AH757IBR/at/593jjm2kqnh6sfbrqhw6xk/very-logo-nav.jpg?auto=webp&format=png&width=50&height=50)The Very Group](https://www.eficode.com/cases/the-very-group) - Transforming service management - [![Air France / KLM](https://cdn.bfldr.com/AH757IBR/at/97tfqrj79xwbfhg65stw8x74/air_france_logo-nav.png?auto=webp&format=png&width=50&height=50)Air France / KLM](https://www.eficode.com/cases/air-france-klm-cloud-migration) - Saving \$600,000 a year with Atlassian Cloud - [![Sennheiser](https://cdn.bfldr.com/AH757IBR/at/2ftbs9npn9jw9zmcm96h45/sennheiser-icon-nav.svg)Sennheiser](https://www.eficode.com/cases/sennheiser) - Reaping big with DevOps - [![Vestas](https://cdn.bfldr.com/AH757IBR/at/kvwwcp8q8m36bzk4q45bsbg8/vestas-logo-nav.png?auto=webp&format=png&width=50&height=50)Vestas](https://www.eficode.com/cases/vestas-case) - Scaling infrastructure with Kubernetes - [![Bankdata](https://cdn.bfldr.com/AH757IBR/at/3jbw8hm47xjv6vk6qs3xgmj/bankdata-square-logo-nav.png?auto=webp&format=png&width=50&height=50)Bankdata](https://www.eficode.com/videos/bankdata-eficode-customer-reference) - Improving developer productivity with Eficode ROOT - [![people at lobby](https://www.eficode.com/hs-fs/hubfs/Eficode%202020%20site%20images/careers-page_people-at-lobby-200.jpg?width=200&name=careers-page_people-at-lobby-200.jpg)**How we help our clients** Our clients say it best: true expertise, seamless communication, and great business outcomes.](https://www.eficode.com/cases/how-we-help) - [Insights](https://www.eficode.com/insights) - Insights - [See the latest](https://www.eficode.com/insights) - Featured topics - [AI and DevOps](https://www.eficode.com/insights/devops-and-ai) - [Atlassian Cloud](https://www.eficode.com/insights/atlassian-cloud) - [Platform engineering](https://www.eficode.com/insights/platform-engineering) - [ITSM](https://www.eficode.com/insights/itsm) - [GitHub Enterprise](https://www.eficode.com/insights/github-enterprise) - [Enterprise Service Management](https://www.eficode.com/insights/enterprise-service-management) - [DevOps transformation](https://www.eficode.com/insights/devops-transformation) - [Agile at Scale](https://www.eficode.com/insights/agile-at-scale) - [Portfolio management](https://www.eficode.com/insights/portfolio-management) - Resources - [Events](https://www.eficode.com/events) - [Blogs](https://www.eficode.com/blog) - [Guides](https://www.eficode.com/guides) - [Podcasts](https://www.eficode.com/devops-podcast) - [Videos](https://www.eficode.com/videos) - [About](https://www.eficode.com/who-we-are) - About - [Who we are](https://www.eficode.com/who-we-are) - [Contact us](https://www.eficode.com/contact) - Our offices and contact details - [Careers](https://www.eficode.com/careers) - Join our team - [Newsroom](https://www.eficode.com/about/newsroom) - Latest news and press info - [Partners](https://www.eficode.com/about/partners) - Technology vendors we work with - [Open source projects](https://www.eficode.com/about/open-source-projects) - The projects we contribute to - [Corporate responsibility](https://www.eficode.com/about/corporate-responsibility) - Addressing our impact to help make better decisions - [![](https://mb.cision.com/Public/18902/4288915/b6ad2e03095aa9e5_200x200ar.jpeg)**Latest company news** Eficode unifies global operations to power the AI-driven future of software development](https://www.eficode.com/press-releases/eficode-unifies-global-operations-to-power-the-ai-driven-future-of-software-development) - [Contact us](https://www.eficode.com/contact) # What to do when you commit to the wrong Git branch ![](https://www.eficode.com/hs-fs/hubfs/Eficode%202020%20site%20images/Blog%20images/Git-branch-blog.png?width=640&height=480&name=Git-branch-blog.png) ### It’s a sunny day, you are having a great time coding, and being the diligent individual you are, you commit regularly. ### And then it hits you: several commits, all to the wrong branch. What now? Well, this is Git we are talking about, so the good news is that it’s relatively straightforward. Let’s say you committed to master, and you meant to commit to a new branch called “myfeature”. There are two things that need fixing. First of all, you need to revert the master back to where it originally was. And secondly, you need to get your changes on that new branch. **Now here are your options:** - **Undo commits on master, checkout new branch myfeature and commit all your changes as one commit.** - **Modify refs manually for the master to point back to where you were and for your new branch ref to.** The first solution is nice, simple and easy to apply without a relatively small margin for error. The downside is, however, that you don’t get your original commit messages on the new branch, and all changes are applied as a single commit with a new commit message etc. The second solution is a little more involved. However, it means that all your commits are passed over to the new branch – though, of course, you should check your results before pushing up to your central repo, as it is slightly easier to get wrong. ## Undo and Commit to New Branch Make sure you are on the branch to which you have been committing. Use git log to check how many commits you want to roll back. Then undo the commits with `git reset HEAD~N`where “N” is the number of commits you want to undo. For example, to undo one commit: `git reset HEAD~1` Then create a new branch and check it out in one go and add and commit your changes again. `git checkout -b newbranch` `git add -A` `git commit -m "Committed on new branch"` Be careful with the `add -A` though as you may be adding unrelated uncommitted files and directories. Have a look at `git status` before you commit to checking. ## Move Commits to the Other Branch There is more margin for error with this one. The first step is to take a note of the commit id of the commit you want to make the head of the new branch. `git log` Copy the commit id to somewhere safe. Then reset your current branch back by one commit (or however many commits you need to go back): `git reset --hard HEAD~1` And the final step is to move the commits that follow to the new branch: `git checkout -b newbranch` `git reset --hard < commit_id >` And it’s done! Time to push both branches (with `--force` if needed, i.e. if you had previously pushed the changes). However, as always, when using `--force` make sure there are no other commits that follow yours as they would be undone. New to Git? Find out more and [get in touch\!](https://www.eficode.com/contact?hsLang=en) Published: April 12, 2018 Updated: May 5, 2025 [DevOps](https://www.eficode.com/blog/topic/devops)[Atlassian](https://www.eficode.com/blog/topic/atlassian) ![Eficode](https://www.eficode.com/hs-fs/hubfs/Eficode%202020%20site%20images/logos/eficode-main-logo-blog.png?width=150&name=eficode-main-logo-blog.png) Eficode [See more from author](https://www.eficode.com/blog/author/eficode) #### Related ![Swiss Software Festival](https://www.eficode.com/hs-fs/hubfs/swiss-software-festival-2026.jpg?width=400&name=swiss-software-festival-2026.jpg) Event #### Swiss Software Festival Date: 24.6.2026 [Read more](https://www.swiss-software-festival.ch/home.html) ![](https://www.eficode.com/hs-fs/hubfs/Eficode%202020%20site%20images/Blog%20images/git.png?width=400&name=git.png) Published: September 15, 2020 #### What to do when you commit to the wrong Git branch pt. 2 [Read more](https://www.eficode.com/blog/what-to-do-when-you-commit-to-the-wrong-git-branch-pt-2?hsLang=en) ![Keep your Git commits clean - Man cleans git branches - eficode](https://www.eficode.com/hs-fs/hubfs/images/blogs/keep%20your%20git%20commits%20clean.png?width=400&name=keep%20your%20git%20commits%20clean.png) Published: March 22, 2021 #### Keep your Git commits clean [Read more](https://www.eficode.com/blog/keep-your-git-commits-clean?hsLang=en) ![Build better software faster—with DevOps and AI on your side](https://www.eficode.com/hs-fs/hubfs/Eficode%202020%20site%20images/Heros_2023/Devops_transformation_image_social.png?width=400&name=Devops_transformation_image_social.png) DevOps services #### Build better software faster—with DevOps and AI on your side [Read more](https://www.eficode.com/services/devops-transformation?hsLang=en) ![Git training](https://www.eficode.com/hs-fs/hubfs/Eficode%202020%20site%20images/Training%20and%20Academy/Training%20themed%20illustration%20-%20Git.png?width=400&name=Training%20themed%20illustration%20-%20Git.png) #### Git training [Read more](https://www.eficode.com/services/devops-training/git?hsLang=en) ![Webpage CTA Icon](https://www.eficode.com/hs-fs/hubfs/Eficode%202020%20site%20images/Blog%20images/Webpage%20CTA%20Icon.png?width=200&name=Webpage%20CTA%20Icon.png) ##### Empower your team with new skills in Atlassian [Get the right Atlassian training for your teams](https://www.eficode.com/services/atlassian-training?hsLang=en) ![Eficode](https://www.eficode.com/hubfs/eficode-hs-theme/images/eficode-main-logo-white.svg) Services - [AI in software development](https://www.eficode.com/services/ai-success-roadmap-for-software-development?hsLang=en) - [DevOps transformation](https://www.eficode.com/services/devops-transformation?hsLang=en) - [Atlassian](https://www.eficode.com/solutions/atlassian?hsLang=en) - [GitHub](https://www.eficode.com/solutions/github-enterprise?hsLang=en) - [GitLab](https://www.eficode.com/solutions/gitlab?hsLang=en) Learning - [Training](https://www.eficode.com/services/training?hsLang=en) - [Blogs](https://www.eficode.com/blog?hsLang=en) - [Client stories](https://www.eficode.com/cases?hsLang=en) - [Events](https://www.eficode.com/events?hsLang=en) - [Guides](https://www.eficode.com/guides?hsLang=en) Eficode - [Contact us](https://www.eficode.com/contact?hsLang=en) - [About](https://www.eficode.com/who-we-are?hsLang=en) - [Newsroom](https://www.eficode.com/about/newsroom?hsLang=en) - [Careers](https://www.eficode.com/careers?hsLang=en) - [Trust Center UK](https://www.eficode.com/trust-centre-uk?hsLang=en) Subscribe to our newsletter - [info@eficode.com](mailto:info@eficode.com) © Copyright Eficode 2026 \| [Privacy policy](https://www.eficode.com/privacy-policy?hsLang=en) \| Cookie Settings \| [Modern slavery statement UK](https://cdn.bfldr.com/AH757IBR/as/p58g5n2wg6g466hjjkjt5fgc/Modern_slavery_statement_of_Eficode_UK_Ltd_-_Branded_PDF) \| [Trust Center](https://trust.upguard.com/82a61be2-f797-4eba-aa69-66d904bdd18f) ![newsletter](https://cdn.bfldr.com/AH757IBR/at/3rw93kgqxtbbpcvvmbk2vvw/newsletter-popup-image.png?auto=webp&format=png)
Readable Markdown
It’s a sunny day, you are having a great time coding, and being the diligent individual you are, you commit regularly. And then it hits you: several commits, all to the wrong branch. What now? Well, this is Git we are talking about, so the good news is that it’s relatively straightforward. Let’s say you committed to master, and you meant to commit to a new branch called “myfeature”. There are two things that need fixing. First of all, you need to revert the master back to where it originally was. And secondly, you need to get your changes on that new branch. **Now here are your options:** **Undo commits on master, checkout new branch myfeature and commit all your changes as one commit.** **Modify refs manually for the master to point back to where you were and for your new branch ref to.** The first solution is nice, simple and easy to apply without a relatively small margin for error. The downside is, however, that you don’t get your original commit messages on the new branch, and all changes are applied as a single commit with a new commit message etc. The second solution is a little more involved. However, it means that all your commits are passed over to the new branch – though, of course, you should check your results before pushing up to your central repo, as it is slightly easier to get wrong. Undo and Commit to New Branch Make sure you are on the branch to which you have been committing. Use git log to check how many commits you want to roll back. Then undo the commits with `git reset HEAD~N`where “N” is the number of commits you want to undo. For example, to undo one commit: `git reset HEAD~1` Then create a new branch and check it out in one go and add and commit your changes again. `git checkout -b newbranch` `git add -A` `git commit -m "Committed on new branch"` Be careful with the `add -A` though as you may be adding unrelated uncommitted files and directories. Have a look at `git status` before you commit to checking. Move Commits to the Other Branch There is more margin for error with this one. The first step is to take a note of the commit id of the commit you want to make the head of the new branch. `git log` Copy the commit id to somewhere safe. Then reset your current branch back by one commit (or however many commits you need to go back): `git reset --hard HEAD~1` And the final step is to move the commits that follow to the new branch: `git checkout -b newbranch` `git reset --hard < commit_id >` And it’s done! Time to push both branches (with `--force` if needed, i.e. if you had previously pushed the changes). However, as always, when using `--force` make sure there are no other commits that follow yours as they would be undone. New to Git? Find out more and [get in touch\!](https://www.eficode.com/contact?hsLang=en) Published: April 12, 2018 Updated: May 5, 2025 [DevOps](https://www.eficode.com/blog/topic/devops)[Atlassian](https://www.eficode.com/blog/topic/atlassian)
Shard93 (laksa)
Root Hash17242050800868332493
Unparsed URLcom,eficode!www,/blog/what-to-do-when-you-commit-to-the-wrong-git-branch s443