MathStudent
MathStudent

Reputation: 310

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

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.

Upvotes: 0

Views: 3090

Answers (1)

knittl
knittl

Reputation: 265281

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)

Upvotes: 2

Related Questions