I know this sounds a little weird, but sometimes manually editing is more convenient than merging and resolving conflicts. I would like GitHub/GitLab to show a merged
label on the branches I manually "merged". Can I do that?
To merge branches locally, use git checkout to switch to the branch you want to merge into. This branch is typically the main branch. Next, use git merge and specify the name of the other branch to bring into this branch.
You can use the git merge-base command to find the latest common commit between the two branches. If that commit is the same as your branch head, then the branch has been completely merged.
In GitHub Desktop, click Current Branch. Click Choose a branch to merge into BRANCH. Click the branch you want to merge into the current branch, then click Merge BRANCH into BRANCH. Note: If there are merge conflicts, GitHub Desktop will warn you above the Merge BRANCH into BRANCH button.
One way you can do this is to actually do a git merge
, but use the -s ours
merge strategy to ignore any actual contribution from the branch. From the git merge documentation:
ours
This resolves any number of heads, but the resulting tree of the merge is always that of the current branch head, effectively ignoring all changes from all other branches. It is meant to be used to supersede old development history of side branches. Note that this is different from the -Xours option to the recursive merge strategy.
This would be suitable to use after you have manually edited a branch to "merge" it, but then want to inform Git that the branch has in fact been logically merged.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With