I have a doubt, I regularly create a branch for new things that are going to be integrated later, so when I do a PR or an MR, as you know it, I try to delete my local branch and once the merge with the test branch is done, but I get an error.
error: The branch mySuperBranch is not fully merged
If you are sure you want to delete it, run git branch -D mySuperBranch
What happens if you forced to delete my local branch, the commit of my test branch is deleted and I lose those changes or what happens:
These are the steps I take to get to that point
git add .
git commit -m"my example changes"
git push origin mySuperBranch
*PR/MR (Pull request on github/gitlab) Approved
git checkout test
git pull origin test
git branch -d mySuperBranch
**Mistake
error: The branch mySuperBranch is not fully merged
If you are sure you want to delete it, run git branch -D mySuperBranch
It's ok if I delete the local branch mySuperBranch with -D
If you're sure you want to remove the branch
mySuperBranch
, ignoring the error you're getting, then use the option-D
instead of-d
.-D : Shortcut for
--delete --force
.-d , --delete : Delete a branch. The branch must be fully merged into your upstream branch , or into
HEAD
if the upstream was not set with--track
or--set-upstream-to
.-f , --force : Restart <branch_name> to <start_point>, even if <branch_name> already exists. Without
-f
, git branch refuses to change an existing branch. In combination with-d
(o--delete
), it allows you to delete the branch regardless of its merge status, or even if it points to a valid commit . In combination with-m
(or--move
), it allows to rename the branch even if the new name already exists, the same applies for-c
(or--copy
).Original English text: