ℹ️ 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.8 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://stackoverflow.com/questions/73868831/how-do-i-assign-a-commit-from-one-branch-to-another |
| Last Crawled | 2026-03-16 21:39:32 (22 days ago) |
| First Indexed | not set |
| HTTP Status Code | 200 |
| Meta Title | git - How do I assign a commit from one branch to another? - Stack Overflow |
| Meta Description | null |
| Meta Canonical | null |
| Boilerpipe Text | Our workflow is to create branches via JIRA. I knew a branch (named A) would soon be merged w/ master and that is the work I needed to build on. So what I did was branch off A locally, creating B.
After A was merged w/ master, I created a new branch C with the appropriate branch name.
On branch B there is a single commit, and I would like that work to be as if it were committed on branch C. How do I do this so that it looks as though I never created B off of A?
Update: No work has been done on C at this point; it has just been created. |
| Markdown | [Skip to main content](https://stackoverflow.com/questions/73868831/how-do-i-assign-a-commit-from-one-branch-to-another#content)
1. [About](https://stackoverflow.co/)
2. Products
3. [For Teams](https://stackoverflow.co/internal/)
4. Try new site Try BETA
1. [Stack Internal Implement a knowledge platform layer to power your enterprise and AI tools.](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=stack-overflow-for-teams)
2. [Stack Data Licensing Get access to top-class technical expertise with trusted & attributed content.](https://stackoverflow.co/data-licensing/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=overflow-api)
3. [Stack Ads Connect your brand to the world’s most trusted technologist communities.](https://stackoverflow.co/advertising/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=stack-overflow-advertising)
4. [Releases Keep up-to-date on features we add to Stack Overflow and Stack Internal.](https://stackoverflow.blog/releases/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=releases)
5. [About the company](https://stackoverflow.co/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=about-the-company) [Visit the blog](https://stackoverflow.blog/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=blog)
1. ### [current community](https://stackoverflow.com/)
- [Stack Overflow](https://stackoverflow.com/)
[help](https://stackoverflow.com/help) [chat](https://chat.stackoverflow.com/?tab=explore)
- [Meta Stack Overflow](https://meta.stackoverflow.com/)
### your communities
[Sign up](https://stackoverflow.com/users/signup?ssrc=site_switcher&returnurl=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F73868831%2Fhow-do-i-assign-a-commit-from-one-branch-to-another) or [log in](https://stackoverflow.com/users/login?ssrc=site_switcher&returnurl=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F73868831%2Fhow-do-i-assign-a-commit-from-one-branch-to-another) to customize your list.
### [more stack exchange communities](https://stackexchange.com/sites)
[company blog](https://stackoverflow.blog/)
2. [Log in](https://stackoverflow.com/users/login?ssrc=head&returnurl=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F73868831%2Fhow-do-i-assign-a-commit-from-one-branch-to-another)
3. [Sign up](https://stackoverflow.com/users/signup?ssrc=head&returnurl=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F73868831%2Fhow-do-i-assign-a-commit-from-one-branch-to-another)
1. 1. [Home](https://stackoverflow.com/)
2. [Questions](https://stackoverflow.com/questions)
3. [AI Assist](https://stackoverflow.com/ai-assist)
4. [Tags](https://stackoverflow.com/tags)
5. [Challenges](https://stackoverflow.com/beta/challenges)
6. [Chat](https://chat.stackoverflow.com/?tab=explore)
7. [Articles](https://stackoverflow.blog/contributed?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=so-blog&utm_content=experiment-articles)
8. [Users](https://stackoverflow.com/users)
9. [Companies](https://stackoverflow.com/jobs/companies?so_medium=stackoverflow&so_source=SiteNav)
10. [Collectives]()
11. Communities for your favorite technologies. [Explore all Collectives](https://stackoverflow.com/collectives-all)
2. Stack Internal
Stack Overflow for Teams is now called **Stack Internal**. Bring the best of human thought and AI automation together at your work.
[Try for free](https://stackoverflowteams.com/teams/create/free/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams) [Learn more](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams)
3. [Stack Internal]()
4. Bring the best of human thought and AI automation together at your work. [Learn more](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams-compact)
##### Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
[Learn more about Collectives](https://stackoverflow.com/collectives)
**Stack Internal**
Knowledge at work
Bring the best of human thought and AI automation together at your work.
[Explore Stack Internal](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams-compact-popover)
# [How do I assign a commit from one branch to another?](https://stackoverflow.com/questions/73868831/how-do-i-assign-a-commit-from-one-branch-to-another)
[Ask Question](https://stackoverflow.com/questions/ask)
Asked
3 years, 5 months ago
Modified [3 years, 5 months ago](https://stackoverflow.com/questions/73868831/how-do-i-assign-a-commit-from-one-branch-to-another?lastactivity "2022-09-27 14:13:53Z")
Viewed 3k times
0
Our workflow is to create branches via JIRA. I knew a branch (named A) would soon be merged w/ master and that is the work I needed to build on. So what I did was branch off A locally, creating B.
After A was merged w/ master, I created a new branch C with the appropriate branch name.
On branch B there is a single commit, and I would like that work to be as if it were committed on branch C. How do I do this so that it looks as though I never created B off of A?
Update: No work has been done on C at this point; it has just been created.
- [git](https://stackoverflow.com/questions/tagged/git "show questions tagged 'git'")
[Share](https://stackoverflow.com/q/73868831 "Short permalink to this question")
[Improve this question](https://stackoverflow.com/posts/73868831/edit)
Follow
[edited Sep 27, 2022 at 14:13](https://stackoverflow.com/posts/73868831/revisions "show all edits to this post")
asked Sep 27, 2022 at 13:53
[](https://stackoverflow.com/users/2532615/mathstudent)
[MathStudent](https://stackoverflow.com/users/2532615/mathstudent)
31033 silver badges1313 bronze badges
7
- 3
`git cherry-pick [commit hash of commit]` on the branch you want to commit to
mousetail
– [mousetail](https://stackoverflow.com/users/6333444/mousetail "8,199 reputation")
2022-09-27 13:54:55 +00:00
Commented Sep 27, 2022 at 13:54
- Do you want the history leading to that commit on branch C too, or just the single commit itself? If you want the single commit, cherry pick it (see mousetail's comment), if you want the history leading to it, merge it into C.
joanis
– [joanis](https://stackoverflow.com/users/3216427/joanis "13,066 reputation")
2022-09-27 13:56:03 +00:00
Commented Sep 27, 2022 at 13:56
- I want it to be as if I had created branch C and did all the work I actually did on B. So cherry-pick sounds like the right answer.
MathStudent
– [MathStudent](https://stackoverflow.com/users/2532615/mathstudent "310 reputation")
2022-09-27 13:59:19 +00:00
Commented Sep 27, 2022 at 13:59
- This worked; if you make answer I will accept.
MathStudent
– [MathStudent](https://stackoverflow.com/users/2532615/mathstudent "310 reputation")
2022-09-27 14:01:32 +00:00
Commented Sep 27, 2022 at 14:01
- 1
Are there commits on C? If so, where on C do you want B's commit to go? It would help if you drew a diagram, perhaps.
matt
– [matt](https://stackoverflow.com/users/341994/matt "540,643 reputation")
2022-09-27 14:03:53 +00:00
Commented Sep 27, 2022 at 14:03
\| [Show **2** more comments](https://stackoverflow.com/questions/73868831/how-do-i-assign-a-commit-from-one-branch-to-another "Expand to show all comments on this post")
## 1 Answer 1
Sorted by:
[Reset to default](https://stackoverflow.com/questions/73868831/how-do-i-assign-a-commit-from-one-branch-to-another?answertab=scoredesc#tab-top)
2
There are many options:
- Simply rename your B branch to C: `git branch -m C B`
- Or branch C off B and abandon B: `git checkout -b C B` (eventually: `git branch -d B`).
- To copy the commit (as new commit with different SHA1 hash) to branch C: `git cherry-pick B` (while on branch C)
[Share](https://stackoverflow.com/a/73868929 "Short permalink to this answer")
[Improve this answer](https://stackoverflow.com/posts/73868929/edit)
Follow
[edited Sep 27, 2022 at 14:02](https://stackoverflow.com/posts/73868929/revisions "show all edits to this post")
answered Sep 27, 2022 at 14:00
[](https://stackoverflow.com/users/112968/knittl)
[knittl](https://stackoverflow.com/users/112968/knittl)
270k5959 gold badges339339 silver badges408408 bronze badges
Sign up to request clarification or add additional context in comments.
## 5 Comments
Add a comment
[](https://stackoverflow.com/users/2532615/mathstudent)
MathStudent
[MathStudent](https://stackoverflow.com/users/2532615/mathstudent)
[Over a year ago](https://stackoverflow.com/questions/73868831/how-do-i-assign-a-commit-from-one-branch-to-another#comment130433620_73868929)
Will this have any issues with not tracking the remote branch?
2022-09-27T14:02:35.863Z+00:00
0
Reply
- Copy link
[](https://stackoverflow.com/users/112968/knittl)
knittl
[knittl](https://stackoverflow.com/users/112968/knittl)
[Over a year ago](https://stackoverflow.com/questions/73868831/how-do-i-assign-a-commit-from-one-branch-to-another#comment130433651_73868929)
@MathStudent remote-tracking branch can be changed with `git branch --set-upstream-to=UPSTREAM`, if it needs to be changed
2022-09-27T14:03:40.96Z+00:00
0
Reply
- Copy link
[](https://stackoverflow.com/users/341994/matt)
matt
[matt](https://stackoverflow.com/users/341994/matt)
[Over a year ago](https://stackoverflow.com/questions/73868831/how-do-i-assign-a-commit-from-one-branch-to-another#comment130433676_73868929)
I'm not sure the OP has given enough info to answer the question yet.
2022-09-27T14:04:27.517Z+00:00
0
Reply
- Copy link
[](https://stackoverflow.com/users/2532615/mathstudent)
MathStudent
[MathStudent](https://stackoverflow.com/users/2532615/mathstudent)
[Over a year ago](https://stackoverflow.com/questions/73868831/how-do-i-assign-a-commit-from-one-branch-to-another#comment130434009_73868929)
If I try moving: "fatal: A branch named 'C' already exists." Is it safe to just delete C locally since no work has been done?
2022-09-27T14:20:06.05Z+00:00
0
Reply
- Copy link
[](https://stackoverflow.com/users/112968/knittl)
knittl
[knittl](https://stackoverflow.com/users/112968/knittl)
[Over a year ago](https://stackoverflow.com/questions/73868831/how-do-i-assign-a-commit-from-one-branch-to-another#comment130438005_73868929)
@MathStudent yes, it is safe to delete. A branch in Git is simply a label given to a commit. If C was created from B, but no commits made, then `B^{commit}==C^{commit}`
2022-09-27T17:14:04.56Z+00:00
0
Reply
- Copy link
Add a comment
Start asking to get answers
Find the answer to your question by asking.
[Ask question](https://stackoverflow.com/questions/ask)
Explore related questions
- [git](https://stackoverflow.com/questions/tagged/git "show questions tagged 'git'")
See similar questions with these tags.
- The Overflow Blog
- [Open source for awkward robots](https://stackoverflow.blog/2026/03/13/open-source-for-awkward-robots/)
- [Domain expertise still wanted: the latest trends in AI-assisted knowledge for...](https://stackoverflow.blog/2026/03/16/domain-expertise-still-wanted-the-latest-trends-in-ai/ "Domain expertise still wanted: the latest trends in AI-assisted knowledge for developers")
- Featured on Meta
- [Logo updates to Stack Overflow's visual identity](https://meta.stackexchange.com/questions/417394/logo-updates-to-stack-overflows-visual-identity)
- [Policy: Generative AI (e.g., ChatGPT) is banned](https://meta.stackoverflow.com/questions/421831/policy-generative-ai-e-g-chatgpt-is-banned)
- [Release notes and bug fixes for beta.stackoverflow.com](https://meta.stackoverflow.com/questions/438499/release-notes-and-bug-fixes-for-beta-stackoverflow-com)
- [I’m Jody, the Chief Product and Technology Officer at Stack Overflow. Let’s...](https://meta.stackoverflow.com/questions/438369/i-m-jody-the-chief-product-and-technology-officer-at-stack-overflow-let-s-talk "I’m Jody, the Chief Product and Technology Officer at Stack Overflow. Let’s talk about the site redesign")
#### Related
[31](https://stackoverflow.com/questions/1773731/in-git-how-do-i-remove-a-commit-from-one-branch-and-apply-it-to-a-different-bra "Question score (upvotes - downvotes)")
[In git, how do I remove a commit from one branch and apply it to a different branch?](https://stackoverflow.com/questions/1773731/in-git-how-do-i-remove-a-commit-from-one-branch-and-apply-it-to-a-different-bra)
[3](https://stackoverflow.com/questions/12677493/how-to-move-certain-commit-to-new-branch "Question score (upvotes - downvotes)")
[How to move certain commit to NEW branch](https://stackoverflow.com/questions/12677493/how-to-move-certain-commit-to-new-branch)
[0](https://stackoverflow.com/questions/26617655/git-copy-commit-from-a-branch-to-another "Question score (upvotes - downvotes)")
[git copy commit from a branch to another](https://stackoverflow.com/questions/26617655/git-copy-commit-from-a-branch-to-another)
[12](https://stackoverflow.com/questions/33024374/how-to-copy-commits-from-one-branch-to-another "Question score (upvotes - downvotes)")
[How to copy commits from one branch to another](https://stackoverflow.com/questions/33024374/how-to-copy-commits-from-one-branch-to-another)
[226](https://stackoverflow.com/questions/36778375/git-apply-a-commit-on-another-branch-to-the-working-copy-share-content-betwe "Question score (upvotes - downvotes)")
[git - apply a commit on another branch to the working copy / Share content between branches and repositories](https://stackoverflow.com/questions/36778375/git-apply-a-commit-on-another-branch-to-the-working-copy-share-content-betwe)
[0](https://stackoverflow.com/questions/37039432/how-to-move-a-commit-between-branches "Question score (upvotes - downvotes)")
[How to move a commit between branches?](https://stackoverflow.com/questions/37039432/how-to-move-a-commit-between-branches)
[0](https://stackoverflow.com/questions/37115596/how-to-copy-a-specific-commit-to-another-branch "Question score (upvotes - downvotes)")
[How to copy a specific commit to another Branch?](https://stackoverflow.com/questions/37115596/how-to-copy-a-specific-commit-to-another-branch)
[0](https://stackoverflow.com/questions/39681211/how-to-associate-a-commit-to-a-branch "Question score (upvotes - downvotes)")
[How to associate a commit to a branch](https://stackoverflow.com/questions/39681211/how-to-associate-a-commit-to-a-branch)
[0](https://stackoverflow.com/questions/50970203/move-a-commit-from-one-branch-to-another-branch "Question score (upvotes - downvotes)")
[Move a commit from one branch to another branch](https://stackoverflow.com/questions/50970203/move-a-commit-from-one-branch-to-another-branch)
[4](https://stackoverflow.com/questions/57272453/how-can-i-copy-commits-from-one-branch-to-another "Question score (upvotes - downvotes)")
[How can I copy commits from one branch to another?](https://stackoverflow.com/questions/57272453/how-can-i-copy-commits-from-one-branch-to-another)
#### [Hot Network Questions](https://stackexchange.com/questions?tab=hot)
- [How do I set a static IP on startup?](https://unix.stackexchange.com/questions/805024/how-do-i-set-a-static-ip-on-startup)
- [Montesquieu on the Civil laws](https://philosophy.stackexchange.com/questions/137049/montesquieu-on-the-civil-laws)
- [Pascal's Triangle \!](https://puzzling.stackexchange.com/questions/137421/pascals-triangle)
- [Regarding Transferred Manuscript](https://academia.stackexchange.com/questions/226200/regarding-transferred-manuscript)
- [Is what I did in the picture "legal"?](https://math.stackexchange.com/questions/5128854/is-what-i-did-in-the-picture-legal)
- [How to get list of installed packages of previous TeX Live installation?](https://tex.stackexchange.com/questions/760883/how-to-get-list-of-installed-packages-of-previous-tex-live-installation)
- [Pi Day: estimating pi using probability](https://mathoverflow.net/questions/509101/pi-day-estimating-pi-using-probability)
- [Tkinter - Demonstration of the Graham-Scan (Convex hull)](https://codereview.stackexchange.com/questions/301608/tkinter-demonstration-of-the-graham-scan-convex-hull)
- [What does it mean to be more electron dense and also slightly positively charged?](https://chemistry.stackexchange.com/questions/195223/what-does-it-mean-to-be-more-electron-dense-and-also-slightly-positively-charged)
- [Do I top up the same amount of new engine oil as much as I drained the old one?](https://mechanics.stackexchange.com/questions/102007/do-i-top-up-the-same-amount-of-new-engine-oil-as-much-as-i-drained-the-old-one)
- [Negative form of imperative nasai form](https://japanese.stackexchange.com/questions/111866/negative-form-of-imperative-nasai-form)
- [How can I diff two huge (250MB+) XML files with only minor changes?](https://superuser.com/questions/1935862/how-can-i-diff-two-huge-250mb-xml-files-with-only-minor-changes)
- [In 1 Corinthians 7:8, does ἀγάμοις (agamois) refer to all unmarried people or specifically to widowers?](https://hermeneutics.stackexchange.com/questions/115343/in-1-corinthians-78-does-%E1%BC%80%CE%B3%CE%AC%CE%BC%CE%BF%CE%B9%CF%82-agamois-refer-to-all-unmarried-people-or-sp)
- [For small island states, would a few nukes be enough to serve as MAD nuclear deterrence?](https://worldbuilding.stackexchange.com/questions/272902/for-small-island-states-would-a-few-nukes-be-enough-to-serve-as-mad-nuclear-det)
- [Boot manager that can load a kernel file on PC with a 8086 CPU](https://retrocomputing.stackexchange.com/questions/32537/boot-manager-that-can-load-a-kernel-file-on-pc-with-a-8086-cpu)
- [When is a theory effective?](https://physics.stackexchange.com/questions/870082/when-is-a-theory-effective)
- [How can I raise the handlebars on this bike?](https://bicycles.stackexchange.com/questions/100088/how-can-i-raise-the-handlebars-on-this-bike)
- [Is there a real function whose graph intersects every circle, no matter how big or small?](https://math.stackexchange.com/questions/5128802/is-there-a-real-function-whose-graph-intersects-every-circle-no-matter-how-big)
- [My basic budget tracker](https://codereview.stackexchange.com/questions/301610/my-basic-budget-tracker)
- [DocumentMetadata impeding the processing of otherwise normal file](https://tex.stackexchange.com/questions/760909/documentmetadata-impeding-the-processing-of-otherwise-normal-file)
- [Why is Trinity Necessary After Jesus' Death? Can't God Exist As One?](https://christianity.stackexchange.com/questions/113376/why-is-trinity-necessary-after-jesus-death-cant-god-exist-as-one)
- [Which Elder Scrolls location is this?](https://gaming.stackexchange.com/questions/418171/which-elder-scrolls-location-is-this)
- [Commentaries on the Organon?](https://philosophy.stackexchange.com/questions/137052/commentaries-on-the-organon)
- [Generic QuickSelect and QuickSort using IComparable\<T\>](https://codereview.stackexchange.com/questions/301593/generic-quickselect-and-quicksort-using-icomparablet)
[more hot questions](https://stackoverflow.com/questions/73868831/how-do-i-assign-a-commit-from-one-branch-to-another)
[Question feed](https://stackoverflow.com/feeds/question/73868831 "Feed of this question and its answers")
# Subscribe to RSS
Question feed
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

##### [Stack Overflow](https://stackoverflow.com/)
- [Questions](https://stackoverflow.com/questions)
- [Help](https://stackoverflow.com/help)
- [Chat](https://chat.stackoverflow.com/?tab=explore)
##### [Business](https://stackoverflow.co/)
- [Stack Internal](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=teams)
- [Stack Data Licensing](https://stackoverflow.co/data-licensing/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=data-licensing)
- [Stack Ads](https://stackoverflow.co/advertising/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=advertising)
##### [Company](https://stackoverflow.co/)
- [About](https://stackoverflow.co/)
- [Press](https://stackoverflow.co/company/press/)
- [Work Here](https://stackoverflow.co/company/work-here/)
- [Legal](https://stackoverflow.com/legal)
- [Privacy Policy](https://stackoverflow.com/legal/privacy-policy)
- [Terms of Service](https://stackoverflow.com/legal/terms-of-service/public)
- [Contact Us](https://stackoverflow.com/contact)
- Cookie Settings
- [Cookie Policy](https://policies.stackoverflow.co/stack-overflow/cookie-policy)
##### [Stack Exchange Network](https://stackexchange.com/)
- [Technology](https://stackexchange.com/sites#technology)
- [Culture & recreation](https://stackexchange.com/sites#culturerecreation)
- [Life & arts](https://stackexchange.com/sites#lifearts)
- [Science](https://stackexchange.com/sites#science)
- [Professional](https://stackexchange.com/sites#professional)
- [Business](https://stackexchange.com/sites#business)
- [API](https://api.stackexchange.com/)
- [Data](https://data.stackexchange.com/)
- [Blog](https://stackoverflow.blog/?blb=1)
- [Facebook](https://www.facebook.com/officialstackoverflow/)
- [Twitter](https://twitter.com/stackoverflow)
- [LinkedIn](https://linkedin.com/company/stack-overflow)
- [Instagram](https://www.instagram.com/thestackoverflow)
Site design / logo © 2026 Stack Exchange Inc; user contributions licensed under [CC BY-SA](https://stackoverflow.com/help/licensing) . rev 2026.3.16.41095 |
| Readable Markdown | Our workflow is to create branches via JIRA. I knew a branch (named A) would soon be merged w/ master and that is the work I needed to build on. So what I did was branch off A locally, creating B.
After A was merged w/ master, I created a new branch C with the appropriate branch name.
On branch B there is a single commit, and I would like that work to be as if it were committed on branch C. How do I do this so that it looks as though I never created B off of A?
Update: No work has been done on C at this point; it has just been created. |
| Shard | 169 (laksa) |
| Root Hash | 714406497480128969 |
| Unparsed URL | com,stackoverflow!/questions/73868831/how-do-i-assign-a-commit-from-one-branch-to-another s443 |