🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 143 (from laksa042)

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
1 day ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0 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://careerkarma.com/blog/git-move-commit-to-another-branch/
Last Crawled2026-04-12 10:57:47 (1 day ago)
First Indexed2020-09-18 01:55:32 (5 years ago)
HTTP Status Code200
Meta TitleGit: Move Commit to Another Branch | Career Karma
Meta DescriptionOn Career Karma, learn how to move a commit from one branch to a new branch or an existing branch in a Git repository.
Meta Canonicalnull
Boilerpipe Text
Code in Git projects is stored in branches . Each branch is an independent line of development in which you can make changes to files. You can move commits from one branch to another branch if you want changes to be reflected on a different branch than the one to which you pushed the changes. In this guide, we discuss how to move a commit to a different branch. We walk through two methods of moving a commit to a different branch: moving to an existing branch, and a new branch. Git Branching: A Refresher Branches let you work on two different versions of a project at the same time. This is useful if you want to fix a bug without changing the main version of a project until that bug is properly fixed. Branches are commonly used when implementing features to keep those features away from the main project until they are ready to be released. You can move a commit to another branch using the Git command line. Git: Move a Commit to a New Branch We’re working on a project and we want to work on a new feature. We want to move a commit we’ve made to the master branch to a new branch called new-feed. This is because the commit will likely be part of a series of commits about a feature and the feature is not ready for a wide release. To move the commit to a new branch, we must first create a new branch: git branch new-feed This command creates a branch containing all the code currently on the “master” branch.  Now that we have a new branch, we can move our master branch back by one commit so it does not contain the code we’ve written toward the new feature: git reset --hard HEAD~1 We are resetting the master branch to the state it was in before the last commit. We can change the number 1 to reflect any number of commits we want to move back. Alternatively, you can specify the hash of a commit if you are not sure how many commits you want to move back relative to the current state of the repository. The next step is to checkout to the new branch to see the version of our project with the features we’ve written: git checkout new-feed Our commit has been moved to the new branch. Git: Move a Commit to an Existing Branch You can move a commit to an existing branch. To start, navigate to the branch to which we want to move our commit using the git checkout command : git checkout new-feed-2 We are now viewing the new-feed-2 branch. Next, we’re going to merge all of the changes we have made to the master branch into the new-feed-2 branch. This will ensure both branches contain the same code: git merge master Now that the new-feed-2 branch contains our changes, we can move back to master and reset our repository to the commit before the one where we pushed our changes: git checkout master git reset --hard HEAD~1 These commands move our master branch back by one commit. This means that our new branch, new-feed-2, contains the code from our changes. The master branch appears in the way it did before we created that commit and pushed it to the master branch. Conclusion You can move a commit to another branch, whether it’s a new branch or an existing one. This is because branches let you maintain independent versions of a project. A new branch contains all of the history of an existing branch and then can create its own history. Now you’re ready to move commits to another branch in Git like a professional developer.
Markdown
![](https://www.facebook.com/tr?id=726791754150577&ev=PageView&noscript=1) Not sure which program is right for you? Talk to our AI Career Advisor now [Start a conversation](https://careerkarma.app/?utm_source=ck-blog&utm_medium=embed&utm_campaign=sitewide&utm_content=top-banner) X Back Bootcamps - [Graduate Stories](https://careerkarma.com/blog/stories/) - [Partner Spotlights](https://careerkarma.com/blog/partner-spotlight/) - [Bootcamp Prep](https://careerkarma.com/blog/bootcamp-prep/) - [Bootcamp Admissions](https://careerkarma.com/blog/bootcamp-admissions/) - [University Bootcamps](https://careerkarma.com/blog/university-bootcamps/) - [Research](https://careerkarma.com/blog/research/) Coding - [Python](https://careerkarma.com/blog/python/) - [Git](https://careerkarma.com/blog/git/) - [JavaScript](https://careerkarma.com/blog/javascript/) - [CSS](https://careerkarma.com/blog/css/) - [Java](https://careerkarma.com/blog/java/) - [HTML](https://careerkarma.com/blog/html/) - [C++](https://careerkarma.com/blog/c-plus-plus/) - [SQL](https://careerkarma.com/blog/sql/) - [Ruby](https://careerkarma.com/blog/ruby/) - [Coding Tools](https://careerkarma.com/blog/coding-tools/) Tech Skills - [Software Engineering](https://careerkarma.com/blog/software-engineering-skills) - [Web Development](https://careerkarma.com/blog/web-development-skills) - [Data Science](https://careerkarma.com/blog/data-science-skills/) - [Design](https://careerkarma.com/blog/design-skills/) - [Tech Guides](https://careerkarma.com/blog/tech-guides/) - [Tech Resources](https://careerkarma.com/blog/tech-resources/) - [Tech Tools](https://careerkarma.com/blog/tech-tools/) Career Resources - [Career Advice](https://careerkarma.com/blog/career-advice/) - [Online Learning](https://careerkarma.com/blog/online-learning/) - [Resume](https://careerkarma.com/blog/resume/) - [Interviews](https://careerkarma.com/blog/interviews/) - [Tech Jobs](https://careerkarma.com/blog/tech-jobs/) - [Internships](https://careerkarma.com/blog/internships/) - [Apprenticeships](https://careerkarma.com/blog/apprenticeships/) - [Tech Salaries](https://careerkarma.com/blog/tech-salaries/) - [Job Market](https://careerkarma.com/blog/job-market/) [Trade School](https://careerkarma.com/blog/trades/) Higher Ed - [Degrees](https://careerkarma.com/blog/degrees/) - [Associate Degree](https://careerkarma.com/blog/associate/) - [Bachelor's Degree](https://careerkarma.com/blog/bachelors/) - [Master's Degree](https://careerkarma.com/blog/masters/) - [Doctoral](https://careerkarma.com/blog/doctoral/) - [University Admissions](https://careerkarma.com/blog/university-admissions/) - [Best Schools](https://careerkarma.com/blog/best-schools/) - [Certifications](https://careerkarma.com/blog/certifications/) Ed Financing - [Bootcamp Financing](https://careerkarma.com/blog/bootcamp-financing/) - [Higher Ed Financing](https://careerkarma.com/blog/higher-ed-financing/) - [Scholarships](https://careerkarma.com/blog/scholarships/) - [Financial Aid](https://careerkarma.com/blog/financial-aid/) Global navigation Browse Bootcamps - Popular Bootcamps - [Artificial Intelligence](https://careerkarma.com/subjects/best-artificial-intelligence-bootcamps) - [Coding](https://careerkarma.com/rankings/best-coding-bootcamps/) - [Cybersecurity](https://careerkarma.com/rankings/best-cyber-security-bootcamps/) - [Data Analytics](https://careerkarma.com/rankings/best-data-analytics-bootcamps/) - [Data Science](https://careerkarma.com/rankings/best-data-science-bootcamps/) - [Design](https://careerkarma.com/rankings/best-web-design-bootcamps/) - [Digital Marketing](https://careerkarma.com/rankings/best-digital-marketing-bootcamps/) - [QA/Testing](https://careerkarma.com/subjects/best-artificial-intelligence-bootcamps) - [Software Engineering](https://careerkarma.com/rankings/best-online-bootcamps/) - [Explore other popular bootcamps](https://careerkarma.com/rankings) - Bootcamps Near You - [Atlanta](https://careerkarma.com/locations/atlanta/) - [Boston](https://careerkarma.com/locations/boston/) - [Chicago](https://careerkarma.com/locations/chicago/) - [Houston](https://careerkarma.com/locations/houston/) - [Los Angeles](https://careerkarma.com/locations/los-angeles/) - [New York City](https://careerkarma.com/locations/new-york/) - [San Francisco](https://careerkarma.com/locations/san-francisco/) - [Seattle](https://careerkarma.com/locations/seattle/) - [View more locations](https://careerkarma.com/locations) - Explore by Subject - [Back End Development](https://careerkarma.com/subjects/best-back-end-bootcamps) - [JavaScript](https://careerkarma.com/subjects/best-javascript-bootcamps/) - [Machine Learning](https://careerkarma.com/subjects/best-machine-learning-bootcamps/) - [Penetration Testing](https://careerkarma.com/subjects/best-penetration-testing-bootcamps) - [Python](https://careerkarma.com/subjects/best-python-bootcamps/) - [React](https://careerkarma.com/subjects/best-react-bootcamps) - [SQL](https://careerkarma.com/subjects/best-sql-bootcamps/) - [View more subjects](https://careerkarma.com/subjects/) Trade Schools - Get Career Advice - [CDL](https://careerkarma.com/blog/trades-cdl) - [HVAC](https://careerkarma.com/blog/trades-hvac) - Match with Programs - [CDL](https://careerkarma.com/fasttrack/cdl) - [HVAC](https://careerkarma.com/fasttrack/hvac) - Programs Near You - [CDL](https://careerkarma.com/blog/browse-cdl-programs) - [HVAC](https://careerkarma.com/blog/browse-hvac-programs) Learn for Free - Browse Questions From Others - [Bootcamps 101](https://careerkarma.com/discussions/tags/beginners/) - [Data Science](https://careerkarma.com/discussions/tags/data-science/) - [Software Engineering](https://careerkarma.com/discussions/tags/software-engineering/) - [Full-Stack Development](https://careerkarma.com/discussions/tags/full-stack-development/) - [JavaScript](https://careerkarma.com/discussions/tags/javascript/) - [Job Search](https://careerkarma.com/discussions/tags/job-search/) - [Career Changes](https://careerkarma.com/discussions/tags/jobs/) - [View all Career Discussions](https://careerkarma.com/discussions/) - Browse Top Careers - [Software Engineering](https://careerkarma.com/careers/software-engineer/) - [Web Development](https://careerkarma.com/careers/web-developer/) - [Mobile App Development](https://careerkarma.com/careers/mobile-development/) - [Data Science](https://careerkarma.com/careers/data-science/) - [Cybersecurity](https://careerkarma.com/careers/cybersecurity/) - [Product Management](https://careerkarma.com/careers/product-management/) - [Digital Marketing](https://careerkarma.com/careers/digital-marketing/) - [UX/UI Design](https://careerkarma.com/careers/design/) - Choosing a Bootcamp - [What is a Coding Bootcamp?](https://careerkarma.com/blog/what-is-a-coding-bootcamp/) - [Are Coding Bootcamps Worth It?](https://careerkarma.com/blog/are-coding-bootcamps-worth-it/) - [How to Choose a Coding Bootcamp](https://careerkarma.com/blog/how-to-choose-a-coding-bootcamp/) - [Best Online Coding Bootcamps and Courses](https://careerkarma.com/blog/best-online-coding-bootcamps/) - [Best Free Bootcamps and Coding Training](https://careerkarma.com/blog/best-free-coding-bootcamps/) - [Coding Bootcamp vs. Community College](https://careerkarma.com/blog/coding-bootcamp-vs-degree/) - [Coding Bootcamp vs. Self-Learning](https://careerkarma.com/blog/coding-bootcamp-versus-self-study/) - [Bootcamps vs. Certifications: Compared](https://careerkarma.com/blog/bootcamps-vs-certifications/) - [What Is a Coding Bootcamp Job Guarantee?](https://careerkarma.com/blog/coding-bootcamp-job-guarantee/) - Paying for a Bootcamp - [How to Pay for Coding Bootcamp](https://careerkarma.com/blog/how-to-pay-for-coding-bootcamp/) - [Ultimate Guide to Coding Bootcamp Loans](https://careerkarma.com/blog/coding-bootcamp-loans/) - [Best Coding Bootcamp Scholarships and Grants](https://careerkarma.com/blog/coding-bootcamp-scholarships/) - [Education Stipends for Coding Bootcamps](https://careerkarma.com/blog/coding-bootcamp-with-living-stipend/) - [Get Your Coding Bootcamp Sponsored by Your Employer](https://careerkarma.com/blog/coding-bootcamp-employer-sponsorship/) - [GI Bill and Coding Bootcamps](https://careerkarma.com/blog/gi-bill-coding-bootcamps/) - Other Topics in Tech - [Tech Intevriews](https://careerkarma.com/blog/interviews/) - [Career Advice](https://careerkarma.com/blog/career-advice/) - [Python](https://careerkarma.com/blog/python/) - [HTML](https://careerkarma.com/blog/html/) - [CSS](https://careerkarma.com/blog/css/) - [JavaScript](https://careerkarma.com/blog/javascript/) - [Git](https://careerkarma.com/blog/git/) - [Java](https://careerkarma.com/blog/java/) - [C++](https://careerkarma.com/blog/c-plus-plus/) About - [Company](https://careerkarma.com/about/) - [Jobs](https://careerkarma.com/company/jobs/) - [Values](https://careerkarma.com/company/values/) - [Publication](https://careerkarma.com/blog/about/) - [Press](https://careerkarma.com/company/press/) - [Partner With Us](https://form.typeform.com/to/f9954oum) - [Stories](https://careerkarma.com/blog/stories/) [Privacy Policy](https://privacy.careerkarma.com/privacy-policy) [Terms of Use](https://careerkarma.com/terms-of-use/) [Do not sell my personal info](https://privacy.careerkarma.com/opt-out) © 2026 Career Karma [![Career Karma](https://careerkarma.com/blog/wp-content/uploads/2023/07/logo-circle-60x60.png)](https://careerkarma.com/) [![Career Karma](https://careerkarma.com/blog/wp-content/uploads/2024/02/ck_logo.png)](https://careerkarma.com/) [Sign In](https://careerkarma.com/sign-in) Get Matched - [Browse Bootcamps](https://careerkarma.com/) - [Popular Bootcamps](https://careerkarma.com/) - [Artificial Intelligence](https://careerkarma.com/subjects/best-artificial-intelligence-bootcamps) - [Coding](https://careerkarma.com/rankings/best-coding-bootcamps/) - [Cybersecurity](https://careerkarma.com/rankings/best-cyber-security-bootcamps/) - [Data Analytics](https://careerkarma.com/rankings/best-data-analytics-bootcamps/) - [Data Science](https://careerkarma.com/rankings/best-data-science-bootcamps/) - [Design](https://careerkarma.com/rankings/best-web-design-bootcamps/) - [Digital Marketing](https://careerkarma.com/rankings/best-digital-marketing-bootcamps/) - [QA/Testing](https://careerkarma.com/subjects/best-artificial-intelligence-bootcamps) - [Software Engineering](https://careerkarma.com/rankings/best-online-bootcamps/) - [Explore other popular bootcamps](https://careerkarma.com/rankings) - [Bootcamps Near You](https://careerkarma.com/) - [Atlanta](https://careerkarma.com/locations/atlanta/) - [Boston](https://careerkarma.com/locations/boston/) - [Chicago](https://careerkarma.com/locations/chicago/) - [Houston](https://careerkarma.com/locations/houston/) - [Los Angeles](https://careerkarma.com/locations/los-angeles/) - [New York City](https://careerkarma.com/locations/new-york/) - [San Francisco](https://careerkarma.com/locations/san-francisco/) - [Seattle](https://careerkarma.com/locations/seattle/) - [View more locations](https://careerkarma.com/locations) - [Explore by Subject](https://careerkarma.com/) - [Back End Development](https://careerkarma.com/subjects/best-back-end-bootcamps) - [JavaScript](https://careerkarma.com/subjects/best-javascript-bootcamps/) - [Machine Learning](https://careerkarma.com/subjects/best-machine-learning-bootcamps/) - [Penetration Testing](https://careerkarma.com/subjects/best-penetration-testing-bootcamps) - [Python](https://careerkarma.com/subjects/best-python-bootcamps/) - [React](https://careerkarma.com/subjects/best-react-bootcamps) - [SQL](https://careerkarma.com/subjects/best-sql-bootcamps/) - [View more subjects](https://careerkarma.com/subjects/) - [Trade Schools](https://careerkarma.com/) - [Get Career Advice](https://careerkarma.com/) - [CDL](https://careerkarma.com/blog/trades-cdl) - [HVAC](https://careerkarma.com/blog/trades-hvac) - [Match with Programs](https://careerkarma.com/) - [CDL](https://careerkarma.com/fasttrack/cdl) - [HVAC](https://careerkarma.com/fasttrack/hvac) - [Programs Near You](https://careerkarma.com/) - [CDL](https://careerkarma.com/blog/browse-cdl-programs) - [HVAC](https://careerkarma.com/blog/browse-hvac-programs) - [Learn for Free](https://careerkarma.com/) - [Browse Questions From Others](https://careerkarma.com/) - [Bootcamps 101](https://careerkarma.com/discussions/tags/beginners/) - [Data Science](https://careerkarma.com/discussions/tags/data-science/) - [Software Engineering](https://careerkarma.com/discussions/tags/software-engineering/) - [Full-Stack Development](https://careerkarma.com/discussions/tags/full-stack-development/) - [JavaScript](https://careerkarma.com/discussions/tags/javascript/) - [Job Search](https://careerkarma.com/discussions/tags/job-search/) - [Career Changes](https://careerkarma.com/discussions/tags/jobs/) - [View all Career Discussions](https://careerkarma.com/discussions/) - [Browse Top Careers](https://careerkarma.com/) - [Software Engineering](https://careerkarma.com/careers/software-engineer/) - [Web Development](https://careerkarma.com/careers/web-developer/) - [Mobile App Development](https://careerkarma.com/careers/mobile-development/) - [Data Science](https://careerkarma.com/careers/data-science/) - [Cybersecurity](https://careerkarma.com/careers/cybersecurity/) - [Product Management](https://careerkarma.com/careers/product-management/) - [Digital Marketing](https://careerkarma.com/careers/digital-marketing/) - [UX/UI Design](https://careerkarma.com/careers/design/) - [Choosing a Bootcamp](https://careerkarma.com/blog/) - [What is a Coding Bootcamp?](https://careerkarma.com/blog/what-is-a-coding-bootcamp/) - [Are Coding Bootcamps Worth It?](https://careerkarma.com/blog/are-coding-bootcamps-worth-it/) - [How to Choose a Coding Bootcamp](https://careerkarma.com/blog/how-to-choose-a-coding-bootcamp/) - [Best Online Coding Bootcamps and Courses](https://careerkarma.com/blog/best-online-coding-bootcamps/) - [Best Free Bootcamps and Coding Training](https://careerkarma.com/blog/best-free-coding-bootcamps/) - [Coding Bootcamp vs. Community College](https://careerkarma.com/blog/coding-bootcamp-vs-degree/) - [Coding Bootcamp vs. Self-Learning](https://careerkarma.com/blog/coding-bootcamp-versus-self-study/) - [Bootcamps vs. Certifications: Compared](https://careerkarma.com/blog/bootcamps-vs-certifications/) - [What Is a Coding Bootcamp Job Guarantee?](https://careerkarma.com/blog/coding-bootcamp-job-guarantee/) - [Paying for a Bootcamp](https://careerkarma.com/blog/) - [How to Pay for Coding Bootcamp](https://careerkarma.com/blog/how-to-pay-for-coding-bootcamp/) - [Ultimate Guide to Coding Bootcamp Loans](https://careerkarma.com/blog/coding-bootcamp-loans/) - [Best Coding Bootcamp Scholarships and Grants](https://careerkarma.com/blog/coding-bootcamp-scholarships/) - [Education Stipends for Coding Bootcamps](https://careerkarma.com/blog/coding-bootcamp-with-living-stipend/) - [Get Your Coding Bootcamp Sponsored by Your Employer](https://careerkarma.com/blog/coding-bootcamp-employer-sponsorship/) - [GI Bill and Coding Bootcamps](https://careerkarma.com/blog/gi-bill-coding-bootcamps/) - [Other Topics in Tech](https://careerkarma.com/blog/) - [Tech Intevriews](https://careerkarma.com/blog/interviews/) - [Career Advice](https://careerkarma.com/blog/career-advice/) - [Python](https://careerkarma.com/blog/python/) - [HTML](https://careerkarma.com/blog/html/) - [CSS](https://careerkarma.com/blog/css/) - [JavaScript](https://careerkarma.com/blog/javascript/) - [Git](https://careerkarma.com/blog/git/) - [Java](https://careerkarma.com/blog/java/) - [C++](https://careerkarma.com/blog/c-plus-plus/) - [About](https://careerkarma.com/) - [Company](https://careerkarma.com/about/) - [Jobs](https://careerkarma.com/company/jobs/) - [Values](https://careerkarma.com/company/values/) - [Publication](https://careerkarma.com/blog/about/) - [Press](https://careerkarma.com/company/press/) - [Partner With Us](https://form.typeform.com/to/f9954oum) - [Stories](https://careerkarma.com/blog/stories/) - [Sign In](https://careerkarma.com/sign-in/) - [Get Matched](https://careerkarma.com/fasttrack/?from=navigationbar) - [Resource Center](https://careerkarma.com/blog/) - [Bootcamps](https://careerkarma.com/blog/bootcamp/) - [Graduate Stories](https://careerkarma.com/blog/stories/) - [Partner Spotlights](https://careerkarma.com/blog/partner-spotlight/) - [Bootcamp Prep](https://careerkarma.com/blog/bootcamp-prep/) - [Bootcamp Admissions](https://careerkarma.com/blog/bootcamp-admissions/) - [University Bootcamps](https://careerkarma.com/blog/university-bootcamps/) - [Research](https://careerkarma.com/blog/research/) - [Coding](https://careerkarma.com/blog/learn-coding/) - [Python](https://careerkarma.com/blog/python/) - [Git](https://careerkarma.com/blog/git/) - [JavaScript](https://careerkarma.com/blog/javascript/) - [CSS](https://careerkarma.com/blog/css/) - [Java](https://careerkarma.com/blog/java/) - [HTML](https://careerkarma.com/blog/html/) - [C++](https://careerkarma.com/blog/c-plus-plus/) - [SQL](https://careerkarma.com/blog/sql/) - [Ruby](https://careerkarma.com/blog/ruby/) - [Coding Tools](https://careerkarma.com/blog/coding-tools/) - [Tech Skills](https://careerkarma.com/blog/tech-skills/) - [Software Engineering](https://careerkarma.com/blog/software-engineering-skills) - [Web Development](https://careerkarma.com/blog/web-development-skills) - [Data Science](https://careerkarma.com/blog/data-science-skills/) - [Design](https://careerkarma.com/blog/design-skills/) - [Tech Guides](https://careerkarma.com/blog/tech-guides/) - [Tech Resources](https://careerkarma.com/blog/tech-resources/) - [Tech Tools](https://careerkarma.com/blog/tech-tools/) - [Career Resources](https://careerkarma.com/blog/career-resource/) - [Career Advice](https://careerkarma.com/blog/career-advice/) - [Online Learning](https://careerkarma.com/blog/online-learning/) - [Resume](https://careerkarma.com/blog/resume/) - [Interviews](https://careerkarma.com/blog/interviews/) - [Tech Jobs](https://careerkarma.com/blog/tech-jobs/) - [Internships](https://careerkarma.com/blog/internships/) - [Apprenticeships](https://careerkarma.com/blog/apprenticeships/) - [Tech Salaries](https://careerkarma.com/blog/tech-salaries/) - [Job Market](https://careerkarma.com/blog/job-market/) - [Trade School](https://careerkarma.com/blog/trades/) - [Higher Ed](https://careerkarma.com/blog/higher-ed/) - [Degrees](https://careerkarma.com/blog/degrees/) - [Associate Degree](https://careerkarma.com/blog/associate/) - [Bachelor’s Degree](https://careerkarma.com/blog/bachelors/) - [Master’s Degree](https://careerkarma.com/blog/masters/) - [Doctoral](https://careerkarma.com/blog/doctoral/) - [University Admissions](https://careerkarma.com/blog/university-admissions/) - [Best Schools](https://careerkarma.com/blog/best-schools/) - [Certifications](https://careerkarma.com/blog/certifications/) - [Ed Financing](https://careerkarma.com/blog/ed-financing/) - [Bootcamp Financing](https://careerkarma.com/blog/bootcamp-financing/) - [Higher Ed Financing](https://careerkarma.com/blog/higher-ed-financing/) - [Scholarships](https://careerkarma.com/blog/scholarships/) - [Financial Aid](https://careerkarma.com/blog/financial-aid/) - [About](https://careerkarma.com/blog/about/) - [Resource Center](https://careerkarma.com/blog/) - [Posts](https://careerkarma.com/blog) - [Git](https://careerkarma.com/blog/git/) - Git: Move Commit to Another Branch # Git: Move Commit to Another Branch ## By ![James Gallagher](https://careerkarma.com/blog/wp-content/uploads/2020/01/james-gallagher-150x150.jpg) **[James Gallagher](https://careerkarma.com/blog/author/jamesgallagher/ "Posts by James Gallagher")** Updated December 1, 2023 [Code in Git projects is stored in branches](https://careerkarma.com/blog/what-is-git/). Each branch is an independent line of development in which you can make changes to files. You can move commits from one branch to another branch if you want changes to be reflected on a different branch than the one to which you pushed the changes. Find your bootcamp match Select Your Interest Your experience Time to start GET MATCHED By completing and submitting this form, you agree that Career Karma Platform, LLC may deliver or cause to be delivered information, advertisements, and telemarketing messages regarding their services by email, call, text, recording, and message using a telephone system, dialer, automated technology or system, artificial or prerecorded voice or message device to your email and/or telephone number(s) (and not any other person’s email or telephone number) that you entered. Consent is not a condition of receiving information, receiving Career Karma services, or using the website, and you may obtain information by emailing [info@careerkarma.com](mailto:info@careerkarma.com). Message & Data rates may apply. Message frequency may vary. Text STOP to unsubscribe. [Terms of Service](https://careerkarma.com/terms-of-use) and [Privacy Policy](https://privacy.careerkarma.com/privacy-policy) govern the processing and handling of your data. X By completing and submitting this form, you agree that Career Karma Platform, LLC may deliver or cause to be delivered information, advertisements, and telemarketing messages regarding their services by email, call, text, recording, and message using a telephone system, dialer, automated technology or system, artificial or prerecorded voice or message device to your email and/or telephone number(s) (and not any other person’s email or telephone number) that you entered. Consent is not a condition of receiving information, receiving Career Karma services, or using the website, and you may obtain information by emailing [info@careerkarma.com](mailto:info@careerkarma.com). Message & Data rates may apply. Message frequency may vary. Text STOP to unsubscribe. [Terms of Service](https://careerkarma.com/terms-of-use) and [Privacy Policy](https://privacy.careerkarma.com/privacy-policy) govern the processing and handling of your data. In this guide, we discuss how to move a commit to a different branch. We walk through two methods of moving a commit to a different branch: moving to an existing branch, and a new branch. ## Git Branching: A Refresher [Branches](https://careerkarma.com/blog/git-branch/) let you work on two different versions of a project at the same time. This is useful if you want to fix a bug without changing the main version of a project until that bug is properly fixed. Branches are commonly used when implementing features to keep those features away from the main project until they are ready to be released. You can move a commit to another branch using the Git command line. ## Git: Move a Commit to a New Branch We’re working on a project and we want to work on a new feature. We want to move a commit we’ve made to the master branch to a new branch called new-feed. This is because the commit will likely be part of a series of commits about a feature and the feature is not ready for a wide release. To move the commit to a new branch, we must first create a new branch: `git branch new-feed` This command creates a branch containing all the code currently on the “master” branch. Now that we have a new branch, we can move our master branch back by one commit so it does not contain the code we’ve written toward the new feature: `git reset --hard HEAD~1` We are [resetting the master branch](https://careerkarma.com/blog/git-reset/) to the state it was in before the last commit. We can change the number 1 to reflect any number of commits we want to move back. Alternatively, you can specify the hash of a commit if you are not sure how many commits you want to move back relative to the current state of the repository. The next step is to checkout to the new branch to see the version of our project with the features we’ve written: `git checkout new-feed` Our commit has been moved to the new branch. ## Git: Move a Commit to an Existing Branch You can move a commit to an existing branch. To start, navigate to the branch to which we want to move our commit using the [git checkout command](https://careerkarma.com/blog/git-checkout/): `git checkout new-feed-2` We are now viewing the new-feed-2 branch. Next, we’re going to [merge all of the changes](https://careerkarma.com/blog/git-merge/) we have made to the master branch into the new-feed-2 branch. This will ensure both branches contain the same code: `git merge master` Now that the new-feed-2 branch contains our changes, we can move back to master and reset our repository to the commit before the one where we pushed our changes: ``` git checkout master git reset --hard HEAD~1 ``` These commands move our master branch back by one commit. This means that our new branch, new-feed-2, contains the code from our changes. The master branch appears in the way it did before we created that commit and pushed it to the master branch. ## Conclusion You can move a commit to another branch, whether it’s a new branch or an existing one. This is because branches let you maintain independent versions of a project. A new branch contains all of the history of an existing branch and then can create its own history. Now you’re ready to move commits to another branch in Git like a professional developer. **About us:** Career Karma is a platform designed to help job seekers find, research, and connect with job training programs to advance their careers. [Learn about the CK publication](https://careerkarma.com/blog/about/). ![Venus profile photo](https://careerkarma.com/blog/wp-content/uploads/2024/02/venus.webp) "Career Karma entered my life when I needed it most and quickly helped me match with a bootcamp. Two months after graduating, I found my dream job that aligned with my values and goals in life!" Venus, Software Engineer at Rockbot Find Your Bootcamp Match #### What's Next? [![icon\_10](https://careerkarma.com/blog/wp-content/uploads/2020/05/get-matched-icon.png) Want to take action? **Get matched** with top bootcamps](https://careerkarma.com/blog/git-move-commit-to-another-branch/) [![icon\_11](https://careerkarma.com/blog/git-move-commit-to-another-branch/%0D%0Ahttps://careerkarma.com/blog/wp-content/uploads/2020/05/ask-icon.png) Want to dive deeper? **Ask** a question to our community](https://careerkarma.com/blog/git-move-commit-to-another-branch/%0D%0Ahttps://careerkarma.com/?utm_campaign=ck-blog&utm_source=whatsnext) [![icon\_12](https://careerkarma.com/blog/git-move-commit-to-another-branch/%0D%0Ahttps://careerkarma.com/blog/wp-content/uploads/2020/05/explore-icon-1.png) Want to explore tech careers? **Take** our careers quiz](https://careerkarma.com/blog/git-move-commit-to-another-branch/%0D%0Ahttps://careerkarma.com/quiz?utm_campaign=ck-blog&utm_source=whatsnext) [![James Gallagher](https://careerkarma.com/blog/wp-content/uploads/2020/01/james-gallagher-300x300.jpg)](https://careerkarma.com/blog/git-move-commit-to-another-branch/) About the Author ![James Gallagher](https://careerkarma.com/blog/wp-content/uploads/2020/01/james-gallagher-150x150.jpg) [James Gallagher](https://careerkarma.com/blog/author/jamesgallagher/) Technical Content Manager at [Career Karma](https://careerkarma.com/) James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tuto... [read more about the author](https://careerkarma.com/blog/author/jamesgallagher/) Share This Sep 17, 2020 [Comments (0)]() ### Leave a Reply [Cancel reply](https://careerkarma.com/blog/git-move-commit-to-another-branch/#respond) [![Apply to top tech training programs in one click](https://careerkarma.com/blog/wp-content/uploads/2022/08/sidebar-bootcamp-img.webp)](https://careerkarma.com/fasttrack/?from=sidebar) Apply to top tech training programs in one click [Get Matched](https://careerkarma.com/fasttrack/?from=sidebar) [![logo](https://careerkarma.com/blog/wp-content/uploads/2024/02/ck_logo.png)](https://careerkarma.com/) [Home](https://careerkarma.com/) [About](https://careerkarma.com/blog/about/) [Jobs](https://careerkarma.com/company/jobs/) [Mission](https://careerkarma.com/company/values/) [Resource Center](https://careerkarma.com/blog/) [Press](https://careerkarma.com/company/press/) [Terms & Сonditions](https://careerkarma.com/terms-of-use/) [Sitemap](https://careerkarma.com/blog/html-sitemap/) [Accessibility Statement](https://careerkarma.com/accessibility-statement/) [Facebook](https://www.facebook.com/CareerKarmaApp) [Twitter](https://twitter.com/Career_Karma) [Instagram](https://www.instagram.com/careerkarma) [Youtube](https://www.youtube.com/careerkarma?sub_confirmation=1) © 2025 Career Karma Careers [Cloud Engineer](https://careerkarma.com/careers/cloud-engineer/) [Customer Success Manager](https://careerkarma.com/careers/customer-success-manager/) [Data Analytics](https://careerkarma.com/careers/data-analytics/) [Data Science](https://careerkarma.com/careers/data-science/) [Interaction Designer](https://careerkarma.com/careers/interaction-designer/) [Machine Learning Engineer](https://careerkarma.com/careers/machine-learning/) [Network Engineer](https://careerkarma.com/careers/network-engineer/) [Quality Assurance Engineer](https://careerkarma.com/careers/quality-assurance-engineer/) [Software Engineer](https://careerkarma.com/careers/software-engineer/) [Tech Sales Representative](https://careerkarma.com/careers/tech-sales-representative/) [View More Career Paths](https://careerkarma.com/careers/) Schools [TripleTen](https://careerkarma.com/schools/tripleten/) [Coding Temple](https://careerkarma.com/schools/coding-temple/) [Flatiron School](https://careerkarma.com/schools/flatiron-school/) [Springboard](https://careerkarma.com/schools/springboard/) [Brainstation](https://careerkarma.com/schools/brainstation/) [SheCodes](https://careerkarma.com/schools/shecodes/) [Code Platoon](https://careerkarma.com/schools/code-platoon/) [Tech Elevator](https://careerkarma.com/schools/tech-elevator/) [Noble Desktop](https://careerkarma.com/schools/noble-desktop/) [Hack Reactor by Galvanize](https://careerkarma.com/schools/hack-reactor/) [View More Schools](https://careerkarma.com/schools/) Tech Bootcamp Prep Research [How to Choose a Coding Bootcamp](https://careerkarma.com/blog/how-to-choose-a-coding-bootcamp/) [Coding Bootcamps with Job Placement Guarantees](https://careerkarma.com/blog/coding-bootcamp-job-placement-rates/) [Accelerated Six Week Coding Bootcamps](https://careerkarma.com/blog/six-week-coding-bootcamp/) [How to Get Into a Coding Bootcamp](https://careerkarma.com/blog/how-to-get-into-coding-bootcamp/) [Preparing for your Coding Bootcamp Interview](https://careerkarma.com/blog/coding-bootcamp-interview-questions/) [View More Bootcamp Prep Research](https://careerkarma.com/blog/bootcamp-prep/) Rankings [Best Coding Bootcamps](https://careerkarma.com/rankings/best-coding-bootcamps/) [Best Online Bootcamps](https://careerkarma.com/rankings/best-online-bootcamps/) [Best Web Design Bootcamps](https://careerkarma.com/rankings/best-web-design-bootcamps/) [Best Data Science Bootcamps](https://careerkarma.com/rankings/best-data-science-bootcamps/) [Best Technology Sales Bootcamps](https://careerkarma.com/rankings/best-technology-sales-bootcamps/) [Best Data Analytics Bootcamps](https://careerkarma.com/rankings/best-data-analytics-bootcamps/) [Best Cyber Security Bootcamps](https://careerkarma.com/rankings/best-cyber-security-bootcamps/) [Best Digital Marketing Bootcamps](https://careerkarma.com/rankings/best-digital-marketing-bootcamps/) [View More Rankings](https://careerkarma.com/schools/) Locations [Atlanta](https://careerkarma.com/locations/atlanta/) [Boston](https://careerkarma.com/locations/boston/) [Chicago](https://careerkarma.com/locations/chicago/) [London](https://careerkarma.com/locations/london/) [Los Angeles](https://careerkarma.com/locations/los-angeles/) [Miami](https://careerkarma.com/locations/miami/) [New York City](https://careerkarma.com/locations/new-york/) [San Francisco](https://careerkarma.com/locations/san-francisco/) [Seattle](https://careerkarma.com/locations/seattle/) [Toronto](https://careerkarma.com/locations/toronto/) [View More Locations](https://careerkarma.com/locations/) Paying for a Tech Bootcamp [How to Pay for Coding Bootcamp](https://careerkarma.com/blog/how-to-pay-for-coding-bootcamp/) [Understanding Coding Bootcamps with Deferred Tuition](https://careerkarma.com/blog/best-coding-bootcamps-with-deferred-tuition/) [GI Bill and Coding Bootcamps](https://careerkarma.com/blog/gi-bill-coding-bootcamps/) [Guide to Coding Bootcamp Scholarships](https://careerkarma.com/blog/coding-bootcamp-scholarships/) [View More Bootcamp Payment Resources](https://careerkarma.com/blog/bootcamp-financing/) Subjects [Python](https://careerkarma.com/subjects/best-python-bootcamps/) [Artificial Intelligence](https://careerkarma.com/subjects/best-artificial-intelligence-bootcamps/) [Back End](https://careerkarma.com/subjects/best-back-end-bootcamps/) [Machine Learning](https://careerkarma.com/subjects/best-machine-learning-bootcamps/) [Penetration Testing](https://careerkarma.com/subjects/best-penetration-testing-bootcamps/) [JavaScript](https://careerkarma.com/subjects/best-javascript-bootcamps/) [Java](https://careerkarma.com/subjects/best-java-bootcamps/) [SQL](https://careerkarma.com/subjects/best-sql-bootcamps/) [React](https://careerkarma.com/subjects/best-react-bootcamps/) [Golang](https://careerkarma.com/subjects/best-golang-bootcamps/) [View More Subjects](https://careerkarma.com/subjects/) Comparisons [App Academy vs Hack Reactor by Galvanize](https://careerkarma.com/comparison/app-academy-vs-hack-reactor/) [Fullstack Academy vs Hack Reactor by Galvanize](https://careerkarma.com/comparison/fullstack-academy-vs-hack-reactor/) [Flatiron School vs Springboard](https://careerkarma.com/comparison/flatiron-school-vs-springboard/) [Brainstation vs Coding Dojo](https://careerkarma.com/comparison/brainstation-vs-coding-dojo/) [Flatiron School vs App Academy](https://careerkarma.com/comparison/flatiron-school-vs-fullstack-academy/) [CareerFoundry vs DesignLab](https://careerkarma.com/comparison/careerfoundry-vs-designlab/) [Springboard vs TripleTen](https://careerkarma.com/comparison/springboard-vs-tripleten/) [General Assembly vs TripleTen](https://careerkarma.com/comparison/general-assembly-vs-tripleten/) [Coding Temple vs General Assembly](https://careerkarma.com/comparison/coding-temple-vs-general-assembly/) [View More Comparisons](https://careerkarma.com/comparison/) Start your Tech training Find, compare, and enroll in the right training program. Save on Tuition. Explore your training options and get exclusive tuition discounts ![Select Arrow](https://careerkarma.com/blog/wp-content/uploads/2024/02/white-arrow-40x32.png)
Readable Markdown
[Code in Git projects is stored in branches](https://careerkarma.com/blog/what-is-git/). Each branch is an independent line of development in which you can make changes to files. You can move commits from one branch to another branch if you want changes to be reflected on a different branch than the one to which you pushed the changes. In this guide, we discuss how to move a commit to a different branch. We walk through two methods of moving a commit to a different branch: moving to an existing branch, and a new branch. ## Git Branching: A Refresher [Branches](https://careerkarma.com/blog/git-branch/) let you work on two different versions of a project at the same time. This is useful if you want to fix a bug without changing the main version of a project until that bug is properly fixed. Branches are commonly used when implementing features to keep those features away from the main project until they are ready to be released. You can move a commit to another branch using the Git command line. ## Git: Move a Commit to a New Branch We’re working on a project and we want to work on a new feature. We want to move a commit we’ve made to the master branch to a new branch called new-feed. This is because the commit will likely be part of a series of commits about a feature and the feature is not ready for a wide release. To move the commit to a new branch, we must first create a new branch: `git branch new-feed` This command creates a branch containing all the code currently on the “master” branch. Now that we have a new branch, we can move our master branch back by one commit so it does not contain the code we’ve written toward the new feature: `git reset --hard HEAD~1` We are [resetting the master branch](https://careerkarma.com/blog/git-reset/) to the state it was in before the last commit. We can change the number 1 to reflect any number of commits we want to move back. Alternatively, you can specify the hash of a commit if you are not sure how many commits you want to move back relative to the current state of the repository. The next step is to checkout to the new branch to see the version of our project with the features we’ve written: `git checkout new-feed` Our commit has been moved to the new branch. ## Git: Move a Commit to an Existing Branch You can move a commit to an existing branch. To start, navigate to the branch to which we want to move our commit using the [git checkout command](https://careerkarma.com/blog/git-checkout/): `git checkout new-feed-2` We are now viewing the new-feed-2 branch. Next, we’re going to [merge all of the changes](https://careerkarma.com/blog/git-merge/) we have made to the master branch into the new-feed-2 branch. This will ensure both branches contain the same code: `git merge master` Now that the new-feed-2 branch contains our changes, we can move back to master and reset our repository to the commit before the one where we pushed our changes: ``` git checkout master git reset --hard HEAD~1 ``` These commands move our master branch back by one commit. This means that our new branch, new-feed-2, contains the code from our changes. The master branch appears in the way it did before we created that commit and pushed it to the master branch. ## Conclusion You can move a commit to another branch, whether it’s a new branch or an existing one. This is because branches let you maintain independent versions of a project. A new branch contains all of the history of an existing branch and then can create its own history. Now you’re ready to move commits to another branch in Git like a professional developer.
Shard143 (laksa)
Root Hash9167054015464201743
Unparsed URLcom,careerkarma!/blog/git-move-commit-to-another-branch/ s443