0

I have a "bugfix" branch on which there are already several commits (I did not post a branch to the server). If I delete this branch, then the commits will be lost in the log?

ioprst
  • 187
  • 16

1 Answers1

1

Yes, Of course all the commits to that branch will be lost. but you can do one thing make a new branch from that commit you can cherry pick the commit and make a new branch.

just take the sha of that commit and cheery pick into another branch checkout to master branch

git checkout master

and then cherry pick that commit

git cheery-pick -x <sha of commit>

now the commit is taken into master branch

now you can delete the branch you want to remove with

git branch -D <branch-name>

  • 1
    Thank you. This is the complete answer to my question. – ioprst Jul 04 '18 at 09:37
  • 1
    "... all the commits to that branch will be lost." Not totally true, the commits will remain until they are garbage collected. A branch is just a pointer to a commit. If you remove the branch you remove the pointer only @ioprst. – sergej Jul 04 '18 at 11:57