Home > Mobile >  How do I assign a commit from one branch to another?
How do I assign a commit from one branch to another?

Time:09-28

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.

CodePudding user response:

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)
  •  Tags:  
  • git
  • Related