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?
Asked
Active
Viewed 112 times
1 Answers
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>

Kavyesh Shah
- 62
- 3
-
1Thank 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